Skip to content
Advertisement

Get all terms in a custom WordPress Query?

I know how to get all of the WordPress terms, but I need a “filtered” down version of the results. Is it possible to get all of the terms that are in the result of a WordPress query? I have this query here:

JavaScript

?>

But I can’t figure how to run the query & put a “Where” clause in it, like you can with MySQL. Any help / suggestion or even point me in the right direction would be greatly appreciated. I’m stuck

Advertisement

Answer

Check this function: wp_get_post_terms()

Assuming your post supports two taxonomies called tax_a and tax_b, you can try something like this, exactly where you wrote your comment:

JavaScript

This will print all the terms for each post retrieved by the query.


EDIT

If what you want is all the terms in all the posts retrieved by the query, you can store the values in an array and then use a function like array_unique(), like this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement