@上面的Krzysiek答案不起作用,因为have\\u posts是一个方法而不是属性。它应该是have\\u posts(),而不是have\\u posts。以下是更正的代码:
$my_query = new WP_Query( array(
\'post_type\'=>\'news\',
\'posts_per_page\'=>4,
\'tax_query\'=>array(
array(
\'taxonomy\'=>\'instituteName\',
\'field\'=>\'slug\',
\'terms\'=>\'businessschool\' // change to real slug
)
)
) );
while ( $my_query->have_posts() ) {
$my_query->the_post();
// display post
}