Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › How to add image source into a custom field? › Reply To: How to add image source into a custom field?
April 3, 2021 at 10:34 am
#32544
Keymaster
That sounds perfect!
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_results_add_custom_image', 10, 1);
function asp_results_add_custom_image($results) {
foreach ( $results as $k => &$r ) {
if ( isset($r->taxonomy) ) {
$vendor = yith_get_vendor( $r->id, 'vendor' );
$r->image = wp_get_attachment_image_src(
$vendor->avatar,
apply_filters( 'yith_wcmv_get_avatar_size', YITH_Vendors()->get_image_size( 'gravatar' ) )
);
}
}
return $results;
}
If all the code they mentioned was right, this should very likely work.
-
This reply was modified 5 years, 2 months ago by
Ernest Marcinko.