Something else may be overriding the search results order. If you look at the WP_Query query variables, are there any orderby
parameters set there?
You need to use the solution in the other thread, because otherwise Relevanssi Light will force the relevance order, but looks like you also need to figure out what else is affecting this. Might be your theme, might be some other plugin.
Here is what I found in my query, is that correct?
ORDER BY relevance DESC, wpim_posts.post_date DESC
No, that is not correct, it sorts by relevance first and date second, and thus doesn’t really get into date sorting.
It should be ORDER BY wpim_posts.post_date DESC
.
Found the issue, The code from other thread, needs to be slightly updated
add_action('init', 'ir_search_hook');
function ir_search_hook() {
remove_filter( 'posts_search_orderby', 'relevanssi_light_posts_search_orderby', 10, 2 );
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;
}
}