Title: Sort By two categories
Last modified: August 31, 2016

---

# Sort By two categories

 *  [iconem](https://wordpress.org/support/users/iconem/)
 * (@iconem)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/sort-by-two-categories/)
 * Hello,
 * I would like to sort the posts displayed based on two post metadata:
    First order
   posts by category, then by date. This way, I would have posts ordered by date
   for each and every category.
 * I’ve seen this can help you make the feature :
    [https://teamtreehouse.com/community/using-multiple-custom-fields-for-orderby-in-wpquery](https://teamtreehouse.com/community/using-multiple-custom-fields-for-orderby-in-wpquery)
 * Another nice feature would be to display Private Posts using another slug.
 * Thanks in advance !
 * Jonathan
 * [https://wordpress.org/plugins/posts-in-page/](https://wordpress.org/plugins/posts-in-page/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [iconem](https://wordpress.org/support/users/iconem/)
 * (@iconem)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/sort-by-two-categories/#post-7157960)
 * Hi,
 * What is needed is simply to allow passing PHP arrays in the orderby attribute
   like so the orderby WP_Query.
 * Thanks again !
 * <?php
    $args = array( ‘post_type’ => ‘words’, ‘meta_query’ => array( array( ‘
   key’ => ‘word_count’, ‘orderby’ => ‘meta_value_num’, ‘order’ => DESC , ), array(‘
   key’ => ‘title’, ‘orderby’ => ‘meta_value’, ‘order’ => DESC ), array( ‘key’ =
   > ‘word_type’, ‘orderby’ => ‘meta_value’, ‘order’ => DESC ), ), ); $query = new
   WP_Query( $args ); ?>
 *  Plugin Author [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/sort-by-two-categories/#post-7158092)
 * Howdy iconem,
 * Thanks for the terrific suggestion. While we don’t currently have this feature(
   multiple meta sorting), but I’ve added your request to our [GitHub repo for Posts in Page](https://github.com/ivycat/Posts-in-Page)
   and we’ll discuss implementing them soon.
 * Issue is here:
    [https://github.com/ivycat/Posts-in-Page/issues/40](https://github.com/ivycat/Posts-in-Page/issues/40)
 * > Another nice feature would be to display Private Posts using another slug.
 * We’ve just added this in a feature branch and are going to test and hope to release
   within a week or two.
 * Cheers,
    Eric
 *  [nsp-code](https://wordpress.org/support/users/nsp-code/)
 * (@nsp-code)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/sort-by-two-categories/#post-7158197)
 * You can do such sort through Advanced Post Types Order plugin, see this article
   [http://www.nsp-code.com/applying-multiple-order-criteria-for-automatic-order-through-fallback-functionality/](http://www.nsp-code.com/applying-multiple-order-criteria-for-automatic-order-through-fallback-functionality/)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Sort By two categories’ is closed to new replies.

 * ![](https://ps.w.org/posts-in-page/assets/icon-256x256.png?rev=1596190)
 * [Posts in Page](https://wordpress.org/plugins/posts-in-page/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-in-page/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-in-page/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-in-page/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-in-page/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-in-page/reviews/)

## Tags

 * [orderby](https://wordpress.org/support/topic-tag/orderby/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * 3 replies
 * 3 participants
 * Last reply from: [nsp-code](https://wordpress.org/support/users/nsp-code/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/sort-by-two-categories/#post-7158197)
 * Status: not resolved