Title: Multiple orderby on query
Last modified: March 16, 2018

---

# Multiple orderby on query

 *  [felzend](https://wordpress.org/support/users/felzend/)
 * (@felzend)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/multiple-orderby-on-query/)
 * Hi, I would like to modify current orderby for multiple terms, being able to 
   order my posts by relevance and post_date. I’ve seen some hook filters, but didn’t
   work for multiple.
 * I’m able to adjust the “orderby” just for one of them manually through the hook,
   but not for multiple.

Viewing 1 replies (of 1 total)

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/multiple-orderby-on-query/#post-10084580)
 *     ```
       add_filter( 'relevanssi_modify_wp_query', 'rlv_set_orderby' );
       function rlv_set_orderby( $query ) {
           $query->set( 'orderby', array(
               'relevance' => 'desc',
               'post_date' => 'desc',
           ));
           return $query;
       }
       ```
   
 * Multiple orderby is just an array of ‘orderby’ => ‘order’ pairs. Relevanssi will
   use them in the order you give them, sorting by the first one first and if that
   gets a tie, then moving on to second and so on.

Viewing 1 replies (of 1 total)

The topic ‘Multiple orderby on query’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=3529670)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

## Tags

 * [date](https://wordpress.org/support/topic-tag/date/)
 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [hook](https://wordpress.org/support/topic-tag/hook/)
 * [multiple](https://wordpress.org/support/topic-tag/multiple/)
 * [orderby](https://wordpress.org/support/topic-tag/orderby/)
 * [relevance](https://wordpress.org/support/topic-tag/relevance/)

 * 1 reply
 * 2 participants
 * Last reply from: [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/multiple-orderby-on-query/#post-10084580)
 * Status: not resolved