WordPress.org

Ready to get started?Download WordPress

Ideas

wp_query / query_posts orderby more than one item

  1. TwoThirdsWater
    Member

    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.

    Thanks!

    Tom

    Posted: 3 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    9 Votes
  • Status

    This idea is under consideration