[wp-hackers] getting post counts for multiple tags
chris at lod.com
Mon May 21 04:00:51 UTC 2012
Actually I just used $wp_query->post_count;
Works fine, on the tag.php template
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Dion Hulse
Sent: Sunday, May 20, 2012 8:12 PM
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] getting post counts for multiple tags
In order to do that, you'd have to make a new WP_Query, query for the tag
intersections, probably limit it to 1 post, and look at the total count it
returns. You could save memory/query time by only asking for the ids of the
You'd want to store the counts in a cache somehow, a transient would
probably suit best.
Of course, that's just my suggestion without resolving to using custom SQL.
On 21 May 2012 01:14, Chris McCoy <chris at lod.com> wrote:
> What would be the best way to go about, finding the amount of posts
> for multiple tags.
> I will be using it on a tag archive page.
> $tag_count = get_term_by('name',
> echo $tag_count->count;
> this works fine for one tag, but I want to check via tag1,tag2,tag3
> tag1+tag2+tag3 how many posts match those
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
wp-hackers mailing list
wp-hackers at lists.automattic.com
More information about the wp-hackers