This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Results override behaviour

#35009
Ernest MarcinkoErnest Marcinko
Keymaster

Oh, so the “popular” is a custom made value, I see why it didn’t work now. Okay, for that, I placed this custom code to the functions.php file in the child theme directory:

add_filter('asp_query_args', 'add_custom_orderby_asp_query_args', 10, 1);
function add_custom_orderby_asp_query_args($args) {
	if ( isset( $_GET['orderby'] ) && 'popular' === $_GET['orderby'] ) {
		$args['post_primary_order'] = "customfp DESC";
		$args['post_primary_order_metatype'] = 'numeric';
		$args['_post_primary_order_metakey'] = 'product_visit_count';
	}
	return $args;
}

It will resolve that.

Well, the filter probably takes the default WooCommerce query as the source and then takes the filtering. However the search override will trigger as well, so they simply override one another. I rather recommend using the filters from ajax search pro instead – it is very rare to get multiple filter plugins work together, generally it is not a good idea.