Patch to enable developers to use different orderings per field specifie... #47

wants to merge 1 commit into


None yet
2 participants

I want a query ordered by menu order and date with both columns sorted in DESC order.

My code is:

$query = new WP_Query(array(
    'orderby'           => 'menu_order date',
    'order'             => 'DESC',

But WP_Query creates this query (which MySQL sorts menu_order ASC because no column ordering was specified):

ORDER BY wp_posts.menu_order,wp_posts.post_date DESC

This PR will create this query:

ORDER BY wp_posts.menu_order DESC,wp_posts.post_date DESC

Or if 'order' => 'DESC ASC' it will create this query:

ORDER BY wp_posts.menu_order DESC,wp_posts.post_date ASC

Just saw the message to use Trac on the other PRs. Apologies.

limal commented Feb 2, 2014

Thanks, James!

It's amazing how it hasn't been supported by Wordpress Query yet. Works great even with complex WooCommerce 2.1. theme.


ghost commented Apr 5, 2014

Hey James. I am using this code to attempt the same situation. I used what you typed above for the parameters.

'orderby' => 'menu_order date',

But I'm really trying to use

'orderby' => 'meta_value_num date',

Either way I get DESC ASC, ... on the first element

Would there be any way you would be willing to revisit this and double check with me? I'm unsure where the ASC is being added as I have found how to set specific parts.

regmagik pushed a commit to regmagik/WordPress that referenced this pull request Nov 9, 2017

Merge pull request #47 from cortex93/master
add a temporay php document root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment