Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › get thumbs from serialied array › Reply To: get thumbs from serialied array
July 9, 2020 at 2:06 pm
#28342
Keymaster
Hi,
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_custom_image_results', 10, 1 );
function asp_custom_image_results( $results ) {
$field_name = 'field_name';
// Parse through each result item
foreach ($results as $k=>&$r) {
if ( $r->content_type == 'pagepost' && empty($r->image) ) {
$field = get_post_meta( $r->id, $field_name , true );
$field = maybe_unserialize($field);
if ( isset($field[0]) )
$r->image = $field[0];
}
}
return $results;
}
Make sure to change the $field_name variable to the custom field name, that holds the image.