Domanda

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)

È stato utile?

Soluzione

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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top