Reply To: Empty search with taxonomy filter not working properly

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Empty search with taxonomy filter not working properly Reply To: Empty search with taxonomy filter not working properly

#8704

ilariaroglieri
Participant

Hi Ernest,
this is the code added in fucntions.php:

add_action( 'pre_get_posts', 'order_by_cf' );
function order_by_cf( $query ) {
	
	if ( is_shop() && $query->is_main_query() || is_product_tag() && $query->is_main_query() || is_tax() && $query->is_main_query() || is_search() && $query->is_main_query() ) {
 
	$query->set('orderby', 'meta_value title');  
        $query->set('meta_key', 'author_name');  
        $query->set('order', 'ASC');
	}
}

as you can see orderby accepts two values (meta value for first, title as secondary).
Of course I would prefer to have this order set for the whole results.
Please let me know what's the best thing to do.
Ilaria