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 2 years, 9 months ago.
- AuthorPosts
- August 13, 2020 at 3:28 pm #28926
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,
nietaAugust 14, 2020 at 9:09 am #28936Hi 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 :)
August 14, 2020 at 10:48 am #28941You cannot access this content.August 15, 2020 at 11:21 am #28964You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
August 15, 2020 at 12:44 pm #28972You cannot access this content.August 15, 2020 at 12:55 pm #28973Well, 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 :)
August 15, 2020 at 1:11 pm #28974You cannot access this content. - AuthorPosts
You must be logged in to reply to this topic.