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

This topic contains 6 replies, has 2 voices, and was last updated by nieta31 nieta31 1 year, 11 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #28926
    nieta31
    nieta31
    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 Marcinko
    Ernest 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.

    Best,
    Ernest Marcinko

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


    #28941
    nieta31
    nieta31
    Participant
    You cannot access this content.
    #28964
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

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


    #28972
    nieta31
    nieta31
    Participant
    You cannot access this content.
    #28973
    Ernest Marcinko
    Ernest 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.

    Best,
    Ernest Marcinko

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


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