[wp-hackers] getting post counts for multiple tags
Dion Hulse (dd32)
wordpress at dd32.id.au
Mon May 21 00:12:07 UTC 2012
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 posts too.
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', get_query_var('tag'),'post_tag');
> echo $tag_count->count;
> this works fine for one tag, but I want to check via tag1,tag2,tag3 and
> tag1+tag2+tag3 how many posts match those
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers