Hello DesignWall team, I have a paid version of DW Focus and I was wondering if you can help me making the search result page sorted by date in descending order.
Thank you for your reply
1 Answers
You can add the following code to the functions.php file:
add_filter('posts_orderby','my_sort_custom',10,2);
function my_sort_custom( $orderby, $query ){
global $wpdb;
if(!is_admin() && is_search())
$orderby = $wpdb->prefix."posts.post_type DESC, {$wpdb->prefix}posts.post_date ASC";
return $orderby;
}
Please login or Register to submit your answer