Same result behavour (no highlighted word but show up)

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 kokosan 1 year, 2 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #41031
    kokosan
    kokosan
    Participant

    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.

    #41038
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #41048
    kokosan
    kokosan
    Participant

    Your eyes are better scanning than my mine regarding this : D. I didn’t even notice that it’s in brackets! Work now, thank you!

    #41049
    kokosan
    kokosan
    Participant

    So, it’s hidden by default, right? In the video I didn’t see it. https://drive.google.com/file/d/12hFgnIUojEy8zsTqomSOAE9aFIZrsAGm/view?usp=sharing

    #41052
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Yes – 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 :)


    #41060
    kokosan
    kokosan
    Participant

    I see.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.