I'm not sure if you can do it with get_pages()
, but you should be able to do something like this with 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 );
I haven't tested this code, but I think it should do what you're looking for.
References
WP_Query
» Custom Field (ie, post meta) parameters ([get_posts()
](https://developer.wordpress.org/reference/functions/get_posts/) arguments follow the same plan asWP_Query
)WP_Query
WP_Query
improvements (includes the information on naming your clauses)