我正在wordpress中显示自定义帖子类型的下拉列表。第一段代码使用WP\\u查询
$houseQuery = new WP_Query(
array(
\'post_type\' => \'house\',
\'order\' => \'ASC\',
\'post_status\' => \'publish\',
\'orderby\' => \'title\',
\'nopaging\' => true,
\'tax_query\' => array(
array(
\'taxonomy\' => \'teamtype\',
\'field\' => \'slug\',
\'terms\' => \'sectorteam\', // exclude house posts in the sectorteam custom teamtype taxonomy
\'operator\' => \'NOT IN\')
))
);
if( $houseQuery ->have_posts() ) :
while ($houseQuery ->have_posts()) : $houseQuery->the_post();
if(get_the_ID()==$c)
$name=$post->post_title;
echo \'{ value:\'.get_the_ID().\', label: "\'.get_the_title(get_the_ID()).\'"},\';
endwhile;
endif;
这是第二段代码,它使用了“wp\\u dropdown\\u page()”方法,更加简洁$args = array (
\'id\' => \'house\',
\'name\' => \'house\',
\'echo\' => 1,
\'post_type\' => \'house\'
);
wp_dropdown_pages($args);
我需要排除第一个示例中“tax\\u query”定义的帖子,但我要确保如何使用“wp\\u dropdown\\u pages”使用的参数来实现这一点。我只想调用一个查询作为解决方案的一部分。