我正在尝试显示标记为WordPress中特定字词的所有帖子,此时它显示自定义帖子类型中的所有帖子,而不是标记到每个字词的帖子。我有一个名为taxonomy-clientType.php的文件,然后这是我用来尝试用正确的帖子填充我的WP_Query的代码
$taxonomy = 'clientType';
$tax_terms = get_terms($taxonomy);
$term = get_queried_object();
// Define the query
$args = array(
'post_type' => 'clients',
'tax_query' => array(
'taxonomy' => 'clientType',
'field' => 'slug',
'terms' => $term->name
)
);
$query = new WP_Query( $args );
谁能看到我哪里出错了?
由于
答案 0 :(得分:2)
尝试:
$args = array(
'post_type' => 'clients',
'tax_query' => array(
array(
'taxonomy' => 'clientType',
'field' => 'slug',
'terms' => $term->name,
),
),
);
$query = new WP_Query( $args );