asked 4 years ago

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
answered 4 years ago

You can add the following code to the functions.php file:

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;
Powered by DW Question & Answer Pro