Reply To: Including Taxonomy Name next to Terms in Results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Including Taxonomy Name next to Terms in Results Reply To: Including Taxonomy Name next to Terms in Results

#10383

Ernest Marcinko
Keymaster

Hi!

Yes, actually it is possible. I've put together a small code snippet for you, put it in the functions.php file in your active theme directory:

add_filter( 'asp_results', 'asp_taxonomy_names_in_terms', 1, 1 );
 
function asp_taxonomy_names_in_terms( $results ) {
  foreach ($results as $k=>$v) {
    if ( $v->content_type == 'term' ) {
      $t = get_taxonomy( $v->taxonomy );
      if ( !is_wp_error($t) )
        $results[$k]->title  = $t->label . ' – ' . $results[$k]->title;
    }
  }
 
  return $results;
}

This should do the trick 🙂

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)