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 26, 2021 at 1:08 pm
#35757
Keymaster
Not exactly, more like:
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) ) {
switch ($taxonomy->labels->name) {
case "Categories":
$name = "category";
break;
case "Tags":
$name = "tag";
break;
default:
$name = $taxonomy->labels->name;
}
$r->title = $name . ": " . $r->title;
}
}
}
return $results;
}