Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Show custom field "auteur" as author › Reply To: Show custom field "auteur" as author
August 19, 2020 at 9:12 am
#29052
Keymaster
Hi,
Sorry, there was a mistake in the code indeed, I have corrected it via FTP, it is all right now:
add_filter( 'asp_results', 'asp_author_from_cf', 10, 1);
function asp_author_from_cf($results) {
foreach ( $results as $k => &$r ) {
$authors = get_the_terms( $r->id, "auteur" );
$author_names = array();
if ( is_array($authors) && count($authors) > 0 ) {
foreach ($authors as $a) {
$author_names[] = $a->name;
}
$r->author = implode(" | ", $author_names);
}
}
return $results;
}