0

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?

1 Answer 1

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()

1
  • Looks good! I'll check this in the morning & let you know.
    – mjjwatson
    Feb 4, 2012 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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