[wp-hackers] getting post counts for multiple tags

Casey Bisson casey.bisson at gmail.com
Mon May 21 02:32:47 UTC 2012


Dion's right, there's no way to do it without some extra work. This plugin generates tag clouds based on the results of the current search or browse:

http://wordpress.org/extend/plugins/scriblio/

Perhaps that's similar to what you're trying to do?

--Casey

On May 20, 2012, at 5:12 PM, Dion Hulse (dd32) wrote:

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