Quantcast
Channel: Multiple meta_key with get_pages - WordPress Development Stack Exchange
Viewing all articles
Browse latest Browse all 2

Answer by Pat J for Multiple meta_key with get_pages

$
0
0

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


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>