Ready to get started?Download WordPress


wp_query / query_posts orderby more than one item

  1. TwoThirdsWater

    I've been fighting a problem for a while now, which could easily be solved by allowing more than one field to orderby.

    I want to sort my posts by X and then by Y.

    eg. sort posts by X, where posts have the same X then sort them by Y.

    This is a standard SQL feature, but not one currently supported by wordpress.

    Currently orderby works like so:
    'orderby' => 'title' or 'orderby' => 'meta_value' etc

    I'd like to suggest that you allow:
    'orderby' => array('title', 'meta_value')
    where the order of the items in the array is the order in which they are sorted.



    Posted: 3 years ago #

RSS feed for this topic


You must log in to post.

  • Rating

    9 Votes
  • Status

    This idea is under consideration