Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Same result behavour (no highlighted word but show up)
This topic contains 5 replies, has 2 voices, and was last updated by kokosan 1 year, 2 months ago.
- AuthorPosts
- January 23, 2023 at 8:59 am #41031
Hi, something to disturb you again, please refer to this close topic https://wp-dreams.com/forums/topic/show-the-post-content-that-has-the-highlighted-word-match-only/. At that time I followed your instruction and checked all the posts from a keyword in the result and confirm it works as I want.
However, I later discover the same result behavour from a keyword. In this case I have searched a keyword and it yields 1,602 related posts in the result. I’ve checked all 1,602 posts one by one and found that only one post doesn’t have any highlighted related word at all but show up in the result (same behavour like in the mentioned close topic). Please have a look https://drive.google.com/file/d/1F-1y9-FL-w3xNkB3lv97Wq46wqzmVQFC/view?usp=sharing
I don’t know why only one post happens among those many posts from this keyword. It may happen with another unpredictable keyword(s) as well that I’ve not yet discovered.
January 23, 2023 at 10:34 am #41038Hi,
No worries, I will help you.
It is actually there, but it’s not showing up because its in brackets: https://i.imgur.com/0lJ8VPx.png
Those brackets are interpreted as a shortcode and WordPress executes it as an empty string. There is a way of getting around it though via a simple custom code:add_filter('asp_results', 'asp_force_fulltext_description'); function asp_force_fulltext_description($results) { foreach($results as $k=>&$r){ $content = get_the_content(null, null, $r->id); $page_num = get_post_meta($r->id, 'page_num', true); $r->content = "<p style='margin-top: 0px;margin-bottom: 15px;'>$content</p><span>$page_num</span>"; } return $results; }
This will fetch the raw content, without the shortcodes rendered, and replace it for the search results. It should display the missing text.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 23, 2023 at 1:08 pm #41048Your eyes are better scanning than my mine regarding this : D. I didn’t even notice that it’s in brackets! Work now, thank you!
January 23, 2023 at 1:24 pm #41049So, it’s hidden by default, right? In the video I didn’t see it. https://drive.google.com/file/d/12hFgnIUojEy8zsTqomSOAE9aFIZrsAGm/view?usp=sharing
January 23, 2023 at 3:17 pm #41052Yes – by default that is executed as a shortcode, but since that is not actually a shortcode it is replaced with nothing.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 23, 2023 at 4:16 pm #41060I see.
- AuthorPosts
You must be logged in to reply to this topic.