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

Reply To: display cpt AND custom Taxonomy next to post title in results page

Home Forums Product Support Forums Ajax Search Pro for WordPress Support display cpt AND custom Taxonomy next to post title in results page Reply To: display cpt AND custom Taxonomy next to post title in results page

#28973
Ernest MarcinkoErnest Marcinko
Keymaster

Well, you can check the $r->taxonomy variable it it exists, if so, then the current result is a taxonomy term:

add_filter( 'asp_results', 'asp_show_the_more_info', 10, 1 );
function asp_show_the_more_info( $results ) {
  foreach ($results as $k=>&$r) {
		if ( isset($r->post_type) ) {
			// Modify the post type post title
			$r->title = get_post_type( $r->id ) . ' - ' . $r->title;
		} else if ( isset($r->taxonomy) ) {
			// Modify the taxonomy term type post title
			$term = get_term( $r->id );
			$r->title = $term->taxonomy . ' - ' . $r->title;
        }
  }
  
  return $results;
}

This will print the taxonomy name or the post type name before the result.