[wp-hackers] get total of posts NOT in selected categories

Rich ZenMaster richzenmaster at gmail.com
Wed Oct 20 11:53:13 UTC 2010


Hi,

I need to get the total number of posts that are not in selected categories.

I have category IDs of the categories that I want to exclude from count (in
the variable $folio_cat_ids)

So far I have this code which is not working,

$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE
post_status = 'publish' AND post_type = 'post' AND post_name NOT LIKE
'%revision%' AND post_name NOT LIKE '%autosave%' AND post_category NOT
IN($folio_cat_ids)");

Please help.


More information about the wp-hackers mailing list