This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Taxonomic labels on category and tag search results

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

#35730
Ernest MarcinkoErnest Marcinko
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.