[wp-hackers] Taxnomy Q: All categories (posts>0) with posts in term X of another taxonomy
Austin Matzko
if.website at gmail.com
Thu Oct 22 10:43:57 UTC 2009
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'));
}
More information about the wp-hackers
mailing list