Question

I want to find all the taxonomies that match an array of CPT id's.

I have a taxonomy called location and I want to find all the locations where they have posts that are equal to my array of post id's e.g. array(12, 13, 18, 22, 343, 5644)

Was it helpful?

Solution

Easiest way to find terms of many posts is to use wp_get_object_terms function

$your_post_ids = array(12, 13, 18, 22, 343, 5644);
$your_taxonomy = 'location' //you can set many as array

$terms = wp_get_object_terms ( $your_post_ids, $your_taxonomy);
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top