你试过了吗WP_Query? 利用我的知识和WP_Query documentation, 我做到了:
$args = array(
\'post_type\' => \'my_post_type\', //change the post type here
\'post_status\' => \'publish\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'my_category\', //change the taxonomy name here
\'field\' => \'id\',
\'include_children\' => false,
\'terms\' => 10 //change the term id here
)
)
);
$_query = new WP_Query($args);
if ($_query->have_posts()):
while ($_query->have_posts()):
$_query->the_post();
//do something here the_title() etc
endwhile;
endif;
wp_reset_query();
魔法应该来自
include_children
属性测试:)
这是你想要的吗?