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

Andrew Nacin wp at andrewnacin.com
Wed Oct 20 12:12:20 UTC 2010


On Wed, Oct 20, 2010 at 7:53 AM, Rich ZenMaster <richzenmaster at gmail.com>wrote:

> 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)
>

Avoid direct queries where possible, unless you're caching them.

To retrieve a list of posts and avoid a certain category, check out
WP_Query, http://codex.wordpress.org/Function_Reference/WP_Query, or
get_posts().

Then check out the category__not_in query var.


More information about the wp-hackers mailing list