The goal is to first try to order by the custom meta field and if its not found then do order by the post date. Here is the query I did so far, but its not working.
$args = array(
'post_type' => 'xyz',
'posts_per_page' => 5,
'meta_query' => array(
'relation' => 'AND',
'query_one' => array(
'key' => 'custom_meta',
'compare' => 'EXISTS',
),
'query_two' => array(
'key' => 'post_date',
),
),
'orderby' => array(
'query_one' => 'DESC',
'query_two' => 'DESC',
),
);
$the_query = new WP_Query( $args );
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745040107a4607758.html
评论列表(0条)