• Hi,

    I have a website where all the pages have a banner with the form on top. When I search for text, the results show up, but in the excerpt, the form select options are rendering. How do I exclude a certain div from searching?

    The page I need help with: [log in to see the link]

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Thread Starter jayaram558

    (@jayaram558)

    Hi Mikko,

    I have tried the below, but unable to excldue the form from the excerpt.

    
    add_filter( 'relevanssi_post_content', 'rlv_remove_menu' );
    add_filter( 'relevanssi_excerpt_content', 'rlv_remove_menu' );
    function rlv_remove_menu( $content ) {
        $content = preg_replace( '~\[et_pb_fullwidth_code admin_label="Get in touch.*?\[/et_pb_fullwidth_code\]~ims', '', $content );
        return $content;
    }
    

    Can you please help. This is the search url – https://www.y-axis.com/?s=canada+pr

    Plugin Author Mikko Saari

    (@msaari)

    Does this slightly wider version work?

    add_filter( 'relevanssi_post_content', 'rlv_remove_menu' );
    add_filter( 'relevanssi_excerpt_content', 'rlv_remove_menu' );
    function rlv_remove_menu( $content ) {
        $content = preg_replace( '~\[et_pb_fullwidth_code.*?Get in touch.*?\[/et_pb_fullwidth_code\]~ims', '', $content );
        return $content;
    }

    If not, can you check what the shortcode exactly looks like in the database? You can use this to check how Relevanssi sees the post: https://www.relevanssi.com/knowledge-base/debugging-indexing-problems/

    Thread Starter jayaram558

    (@jayaram558)

    Hi Mikko,

    The code you have given didn’t help. Unable to exclude the form from top section.

    I have added the debug code. You can see it here – https://www.y-axis.com/visa/work/canada/provincial-nominee-program/

    You can see the output here – https://ibb.co/HpLVjps

    It only shows the HTML of the page but no shortcodes. How do I Exclude the form on top? The form is on 90% of the pages. So all pages are showing the select dropdown options in the excerpt.

    • This reply was modified 4 years, 5 months ago by jayaram558.
    Plugin Author Mikko Saari

    (@msaari)

    Try moving the filters to an earlier priority, ie. change the add_filterpart to this:

    add_filter( 'relevanssi_post_content', 'rlv_remove_menu', 8 );
    add_filter( 'relevanssi_excerpt_content', 'rlv_remove_menu', 8 );

    Does that help?

    • This reply was modified 4 years, 5 months ago by Mikko Saari.
    Thread Starter jayaram558

    (@jayaram558)

    No Luck. it’s still the same.

    Plugin Author Mikko Saari

    (@msaari)

    If you change the code to this and then go save one of the posts with the form, what do you get?

    add_filter( 'relevanssi_post_content', 'rlv_remove_menu', 8 );
    function rlv_remove_menu( $content ) {
        var_dump($content);
        exit();
        return $content;
    }
    Thread Starter jayaram558

    (@jayaram558)

    Here is the results of what you asked – https://pastebin.com/52P16sfB

    Plugin Author Mikko Saari

    (@msaari)

    One more try:

    add_filter( 'relevanssi_post_content', 'rlv_remove_menu', 8 );
    add_filter( 'relevanssi_excerpt_content', 'rlv_remove_menu', 9 );
    function rlv_remove_menu( $content ) {
        $content = preg_replace( '/\[et_pb_fullwidth_code.*?\].*\[\/et_pb_fullwidth_slider\]/im', '', $content );
        return $content;
    }

    This will remove all et_pb_fullwidth_code elements, and matches what Relevanssi does to remove Divi stuff currently. (Using ims may actually be the problem, Relevanssi just uses im.)

    (I’m going to add this to the Relevanssi default behaviour in the next version.)

    Thread Starter jayaram558

    (@jayaram558)

    Hi Mikko,

    Still no luck. its the same and rending the form in search results.

    Plugin Author Mikko Saari

    (@msaari)

    Are you sure those excerpts are generated by Relevanssi in the first place? If the excerpts are generated by Divi, then nothing you do with Relevanssi filters is going to change it. If you adjust the excerpt length, do the excerpts change?

    Thread Starter jayaram558

    (@jayaram558)

    I have changed 30 to 50 in Excerpts and highlights settings. But nothing has changed. Where do I update the settings?

    IF the excerpts are created by divi, how do I change it?

    Thread Starter jayaram558

    (@jayaram558)

    Mikko,

    Ok. I have changed truncate_post( 470 ); to the_excerpt(); in search.php and it worked now. Thanks, Much for your help!

    One more quick question. I have selected to match the full word and unchecked OR fallback. But still, I get both the results. Why is that?

    Example: if I search for Canada pr, I get results for Canada and also PR where if we have a word program, we get that into results. How do we make it an exact match?

    • This reply was modified 4 years, 5 months ago by jayaram558.
    Plugin Author Mikko Saari

    (@msaari)

    If you haven’t touched the advanced indexing settings and adjusted the minimum word length from 3 to 2, “pr” is simply discarded and search for “canada pr” is just a search for “canada”. If you set the minimum word length to 2 and then reindex, the search should work as expected.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Exclude form data into excerpts’ is closed to new replies.