search filter add priority to post_type and add order to some post_type

Here is the code from the provided link after adaptation. add_filter( ‘posts_orderby’, ‘se344727_custom_search_order’, 10, 2 ); function se344727_custom_search_order( $orderby, $query ) { global $wpdb; if (!is_admin() && $query->is_main_query()) { if ($query->is_search) { // — sort by: type, title, date — // ” ELSE 2 END ASC, ” . $orderby; // — sort by: type, date … Read more

Advanced search by two criteria – sort by location and date (ascending or descending)

I finally found a solution. For those who might also stumble on this. What I had to do is to put ASC and DESC as option values for the date sorting. I read in the documentation that WordPress uses these values by default to sort data. <select class=”dropdown-class” name=”order” id=”sortbox”> <option value=”DESC”>Newest</option> <option value=”ASC”>Oldest</option> </select> … Read more