Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Image in search results › Reply To: Image in search results
April 25, 2019 at 10:14 am
#22310
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.