我真的不明白那是怎么回事get_the_term_list
返回HTML字符串。
首先,你需要get_the_terms
和wp_list_pluck
.
其次,你需要tax_query
. 那个{tax} = {term}
模式已弃用。
$this_post = $post->ID;
$args = array(
\'post_type\' => \'dir_entry\',
\'posts_per_page\' => 10,
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'post__not_in\' => array($this_post),
);
$terms = get_the_terms($this_post,\'post_tag\');
if (!is_wp_error($terms)) {
$terms = wp_list_pluck($terms,\'term_id\');
$args[\'tax_query\'] = array(
array(
\'taxonomy\' => \'post_tag\',
\'field\' => \'id\',
\'terms\' => array_values($terms)
)
);
$query = new WP_Query($args);
}