Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Taxonomic labels on category and tag search results › Reply To: Taxonomic labels on category and tag search results
November 25, 2021 at 10:31 am
#35730
Keymaster
Hi,
I’m afraid there is no option for that, but it could be doable via some minor custom code.
add_filter('asp_results', 'asp_display_tax_name_in_results');
function asp_display_tax_name_in_results($results) {
foreach($results as $k=>&$r){
if ( $r->content_type == 'term' ) {
$taxonomy = get_taxonomy( $r->taxonomy );
if ( !is_wp_error($taxonomy) ) {
$r->title = $taxonomy->labels->name . ": " . $r->title;
}
}
}
return $results;
}
Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.