Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have an array of term IDs that I'd like to filter my query with, but most wordpress functions seem to need the 'taxonomy' field entered too. Is there a reason for this?

Passing the taxonomy ID seems to be unnecessary, if all term IDs are unique anyway, unless I'm missing something.

As it seems as though I can't query this with Wordpress direct, I'd be looking for something like:

$terms_array = get_term_ids( get_the_ID() );

Any ideas of the best way to pull this off?

share|improve this question

1 Answer 1

Try out this code and see if it works for you, I just cooked it up real quick and haven't tested it, so it may be way off base, but the concept is there.

$tax_args = array(
    'public' => true
);
$taxonomies = get_taxonomies( $tax_args, 'names', 'or' );

$term_args = array(
    'fields' => 'ids'
);
$terms = get_terms( $taxonomies, $term_args );

Docs: get_taxonomies(), get_terms()

share|improve this answer
    
Looks good! I'll check this in the morning & let you know. –  mjjwatson Feb 4 '12 at 20:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.