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

Andrew Nacin wp at andrewnacin.com
Wed Oct 20 14:29:13 UTC 2010


On Wed, Oct 20, 2010 at 10:23 AM, John Blackbourn
<johnbillion+wp at gmail.com<johnbillion%2Bwp at gmail.com>
> wrote:

> On Wed, Oct 20, 2010 at 1:26 PM, Rich ZenMaster <richzenmaster at gmail.com>
> wrote:
> > Actually I don't need the list of posts. Just the post count.
>
> If you fetch the posts using get_posts() as Andrew suggested you can
> then count() them to get the total. The added bonus will be that the
> posts are added to WordPress' object cache.


Especially important if you then need to display these posts.

If you use WP_Query directly, you can use $my_query->post_count.


More information about the wp-hackers mailing list