• Resolved wissam6

    (@wissam6)


    Hello,
    I’m using Divi along Relevanssi. in on of my pages i have a section in the begining of the page, i want to exclude it from the search, is it possible?

    thx

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter wissam6

    (@wissam6)

    sorry i think i was not clear:
    actually when i do search, in the result page it show also the 2-3 first line of my page (i think it is in defined setting “Length of the snippet”). what i need is to not show these lines, i want to skip it, is it possible?

    Plugin Author Mikko Saari

    (@msaari)

    Yes, it’s possible. You can use the relevanssi_excerpt_content filter hook to modify the post before Relevanssi creates the excerpt. Remove the unwanted content from the post in that filter hook, and it won’t appear in the excerpts.

    Thread Starter wissam6

    (@wissam6)

    hi, thanks for your reply, so the post is saying:

    To remove all parts of the post marked with the relevanssi_noindex class from the excerpts, you can use this:
    add_filter( ‘relevanssi_excerpt_content’, ‘rlv_remove_noindex_class’ );
    function rlv_remove_noindex_class( $content ) {
    return preg_replace( ‘#<(.*) class=”.*?relevanssi_noindex”.*?</\1>#ms’, ”, $content );
    }

    but how can i mark a part of my post with this class? (i am using divi and in the beginning of my post i have a section which i don’t want to appear in the excerpt)

    thx

    Plugin Author Mikko Saari

    (@msaari)

    You don’t, that’s just an example of how the filter hook is used, and not related to your case here.

    The $content variable has your post content in it, and you need to create a filter function that removes the unwanted part of the content from the variable and then returns that.

    You can use the example, you just need to replace the #<(.*) class=”.*?relevanssi_noindex”.*?</\1>#ms with a regex that will remove the part you want removed. Since I have no idea what that part looks like, I can’t unfortunately be more specific here.

    Thread Starter wissam6

    (@wissam6)

    THANKS A LOT

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘excluding section’ is closed to new replies.