Вопрос

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)

Это было полезно?

Решение

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);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с wordpress.stackexchange
scroll top