[wp-hackers] Taxnomy Q: All categories (posts>0) with posts in term X of another taxonomy

Dion Hulse (dd32) wordpress at dd32.id.au
Thu Oct 22 10:57:06 UTC 2009


On Thu, 22 Oct 2009 21:43:57 +1100, Austin Matzko <if.website at gmail.com>  
wrote:

> On Thu, Oct 22, 2009 at 5:23 AM, Dion Hulse (dd32)  
> <wordpress at dd32.id.au> wrote:
>> I'm looking for a function which I'm pretty sure isnt offered by  
>> WordPress's
>> Taxonomy system, Yet it seems to be something a few people might need..  
>> So
>> i'm putting a call out to see if anyone has any ideas? (ie. pre-written  
>> code
>> they'd like to share..)
>>
>> What i'm basically wanting, Is to find out the list of categories with  
>> posts
>>> 0 which exist in term X of another taxonomy..
>>
>> An example, Would be, Find all categories with more than 0 posts which  
>> are
>> contained within the tag 'SomeTag'
>
> Unless I misunderstand what you want, wouldn't the following work?
>
> $term = get_term_by('name', 'SomeTag', 'post_tag');
> if ( ! empty( $term->term_id ) ) {
> 	$cat_ids = (array) wp_get_object_terms(get_objects_in_term(
> array($term->term_id), array('post_tag')), array('category'),
> array('fields' => 'ids'));
> }

Hmm... That may indeed work.. Told you i needed a push in the right  
directiion.

I'll give it a try tomorrow! Thanks Austin


More information about the wp-hackers mailing list