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

Rich ZenMaster richzenmaster at gmail.com
Wed Oct 20 12:26:24 UTC 2010


Actually I don't need the list of posts. Just the post count.

On Wed, Oct 20, 2010 at 5:12 AM, Andrew Nacin <wp at andrewnacin.com> wrote:

> 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.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list