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

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

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #28926
    nieta31nieta31
    Participant

    Hi,

    I succesfully could add the post-type next to the title as described here: https://wp-dreams.com/forums/topic/display-cpt-next-to-post-title/

    But, we would also like to see if the result is a (custom)taxonomy or a (custom)post. What would be that code?
    And also, how to show this also in the results page?

    Hope you can help me figure this out. Great plugin!

    Kind regards,
    nieta

    #28936
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi Nieta,

    Thank you for your kind words!

    Unfortunately the plugin cannot affect that there. I believe this may require editing the corresponding theme file to fetch the information.

    #28941
    nieta31nieta31
    Participant

    You cannot access this content.

    #28964
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

    #28972
    nieta31nieta31
    Participant

    You cannot access this content.

    #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.

    #28974
    nieta31nieta31
    Participant

    You cannot access this content.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.