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
May 17, 2016 at 11:32 am
#8704
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