According to: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
Default order is DESC and default orderby is date.
In a custom plugin, plugin is applying the following pre_get_posts filter:
function custom_search_filter($query) { //echo '<pre>'; var_dump($_GET); echo '</pre>'; die; //echo '<pre>'; var_dump($query); echo '</pre>'; die; if ($query->is_search) { /* -------------------------------------------------- */ $query->set('orderby', 'date'); if ( isset($_GET['order']) ) { if ( $_GET['order'] == 'DESC' ) { $query->set('order', 'DESC'); //echo '<pre>'; var_dump($_GET); echo '</pre>'; die; } else { $query->set('order', 'ASC'); //echo '<pre>'; var_dump($_GET); echo '</pre>'; die; } } /* -------------------------------------------------- */ } return $query; } add_filter('pre_get_posts', 'custom_search_filter', 999); The GET URL sets order to ASC:
And debugging the query I get:
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'resources' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.menu_order, wp_posts.post_date DESC LIMIT 0, 10"
In SQL above, You can notice: ORDER BY ... DESC
Theres a reason why order is not changing from DESC to ASC if actually $_GET['order'] == 'ASC'?
Thanks in advance.