如何显示父分类下的帖子而不是子分类下的帖子 .
这是我的代码
$post_type = 'products';
$tax = 'products_categories';
$newargs=array(
'post_type' => $post_type,
'tax_query' => array (
array(
'taxonomy' => 'products_categories',
'field' => 'id',
'terms' => '$term_id'
)
)
1 回答
我自己找到了答案
以下是仅显示父类别而非子类别的帖子的新代码