• Resolved Dan Greene

    (@dgreene423)


    Relevanssi Light is great and it’s nice to have functioning search again. Is there a way to have the search results sorted by most recent date first?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Relevanssi Light overrides the orderby parameter to set the order to relevance. Adding this to your theme functions.php should switch it to post date:

    remove_filter( 'posts_search_orderby', 'relevanssi_light_posts_search_orderby', 10 );
    add_filter( 'posts_search_orderby', 'rl_posts_search_orderby', 10, 2 );
    function rl_posts_search_orderby( $orderby, $query ) {
    	if ( isset( $query->query['s'] ) ) {
    		$orderby = 'post_date DESC';
    	}
    	return $orderby;
    }
    Thread Starter Dan Greene

    (@dgreene423)

    Thanks Mikko.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Search results sort by most recent date?’ is closed to new replies.