Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › ACF advanced custom Fields in results description › Reply To: ACF advanced custom Fields in results description
March 24, 2018 at 11:23 pm
#17248
Participant
I wrote this. Maybe if you want to share it:
[code]add_filter( ‘asp_results’, ‘asp_custom_field_to_title’, 1, 1 );
function asp_custom_field_to_title( $results ) {
$custom_field = "super";
foreach ($results as $k=>$v) {
$meta_value = get_field(‘file_download’,$results[$k]->id); // ACF support
if($meta_value){
$results[$k]->title .= " – <a href=’" . $meta_value . "’ target=’_blank’>Download</a>";
}
else{
$results[$k]->title;
}
}
return $results;
}[/code]