[wp-trac] [WordPress Trac] #29447: Multiple options for 'orderby' => 'meta_value_num' or making it optional
WordPress Trac
noreply at wordpress.org
Sun Oct 8 10:52:09 UTC 2017
#29447: Multiple options for 'orderby' => 'meta_value_num' or making it optional
-------------------------+-----------------------------
Reporter: wzislam | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Query | Version: 3.9.2
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: performance
-------------------------+-----------------------------
Comment (by gagan0123):
This issue seems to be resolved, as I'm able to write WP_Query with
multiple orderby fields having multiple meta term orders, for eg, a books
CPT with meta keys `author` and `publisher`, we can sort first by
publisher and then by author meta keys using query:
{{{#!php
<?php
$query = new WP_Query( array(
'meta_query' => array(
'relation' => 'AND',
'author' => array(
'key' => 'author',
'compare' => 'EXISTS',
),
'publisher' => array(
'key' => 'publisher',
'compare' => 'EXISTS',
),
),
'orderby' => array(
'publisher' => 'ASC',
'author' => 'ASC',
),
'post_status' => 'publish',
'post_type' => 'book',
) );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29447#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list