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

Reply To: Image in search results

#22310
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

This should be possible, but only by using a custom code. Try adding this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!
Change the $field variable to the user meta field name, it should do the trick:

add_filter( 'asp_results', 'asp_get_custom_cf_image', 10, 1 );
function asp_get_custom_cf_image( $results ) {
	$field = 'user-image-url'; // Enter the user meta field containing the image
	foreach ($results as $k=>&$r) {
		if ( $r->content_type == 'user' ) {
			$img = get_user_meta($r->id, $field, true);
			if ( !is_wp_error($img) && !empty($img) )
				$r->image = $img;
		}
	}
	return $results;
}

If the image URL is stored within that field, then this should work.