那就是wp_get_object_terms
. 您需要一个post-id数组作为输入,以及要检索术语的分类法(比如:books)。这应该有效(未经测试):
$my_query = new wp_query ($args);
$my_posts = $my_query->posts;
$my_post_ids = wp_list_pluck ($my_posts, \'ID\');
$my_terms = wp_get_object_terms ($my_post_ids, \'books\');