Title: Results order
Last modified: August 30, 2018

---

# Results order

 *  [user2015](https://wordpress.org/support/users/user2015/)
 * (@user2015)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/results-order-3/)
 * Hi,
    I have this plugin installed in a library´s website. When I search a book,
   i.e “by title” I´d like to see the results ordered by date (from newest to oldest).
   How should I configure it?
 * Thanks

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

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/results-order-3/#post-10642388)
 * If you want all the searches to return posts by date, just change the setting
   in the Relevanssi settings page.
 * If you want only some searches sorted by date, you can use the `orderby` parameter.
   Set it to `post_date`.
 * For example, you could have a dropdown like this on your search form:
 *     ```
       <select name="orderby">
           <option value="post_date">Date</option>
           <option value="relevance">Relevance</option>
       </select>
       ```
   
 *  Thread Starter [user2015](https://wordpress.org/support/users/user2015/)
 * (@user2015)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/results-order-3/#post-10645195)
 * Thanks for your answer Mikko.
    I think I wasn´t clear. I need to order them by
   the date in which each book was published (ACF field), not the date in which 
   each book was posted.
 * That is:
    Title: XXXX Author: XXXX **Date: 2016**
 * Thanks for your help
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/results-order-3/#post-10645528)
 * Change the select to
 *     ```
       <select name="orderby">
           <option value="publication_date">Date</option>
           <option value="relevance">Relevance</option>
       </select>
       ```
   
 * and add
 *     ```
       add_filter( 'relevanssi_orderby', 'publication_date_orderby' );
       function publication_date_orderby( $orderby ) {
       	if ( 'publication_date' === $orderby ) {
       		global $wp_query;
       		$orderby = 'meta_value_num';
       		$wp_query->query_vars['meta_key'] = 'XXX';
       	}
       	return $orderby;
       }
       ```
   
 * to your functions.php. Just change “XXX” to the name of the date field. There’s
   a small catch, though: this doesn’t work with the current version of Relevanssi.
   It will work with the next version, and also with the current version, if you
   replace the lib/sorting.php file with this one: [https://github.com/msaari/relevanssi/blob/master/lib/sorting.php](https://github.com/msaari/relevanssi/blob/master/lib/sorting.php)

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

The topic ‘Results order’ 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * Last activity: [7 years, 8 months ago](https://wordpress.org/support/topic/results-order-3/#post-10645528)
 * Status: not resolved