我不确定你能不能用get_pages()
, 但你应该可以用get_posts()
:
$args = array(
\'post_type\' => \'page\',
\'meta_query\' => array(
\'template_clause\' => array(
\'key\' => \'_wp_page_template\',
\'value\' => \'unit.php\',
\'compare\' => \'=\',
),
\'status_clause\' => array(
\'key\' => \'status\',
\'compare\' => \'EXISTS\',
),
\'relation\' => \'AND\',
),
\'orderby\' => \'status_clause\',
\'order\' => \'DESC\',
);
$pages = get_posts( $args );
// Better option, per Tom J Nowell\'s comment on the question
$page_query = new WP_Query( $args );
我尚未测试此代码,但我认为它应该满足您的要求。
WP_Query
WP_Query
improvements (包括有关命名条款的信息)