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

Reply To: Displaying products with images first

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Displaying products with images first Reply To: Displaying products with images first

#25473
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

Well, I’m afraid there is no way to do that at the moment via settings. It might be doable though via custom code.

Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

add_filter('asp_results', 'asp_image_results_first', 10, 1);
function asp_image_results_first( $results ) {
	$image_res = array();
	$non_image_res = array();
	foreach ( $results as $k => &$r ) {
		if ( !empty($r->image) ) {
			$image_res[] = $r;
		} else {
			$non_image_res[] = $r;
		}
	}           
	return $image_res + $non_image_res;
}