• I’m trying to customise which parts of the page appear in the search results page. At the top of all the product pages on our store, there are a collection of headers which are too abstract to be usefully descriptive in a search query, but are still taking up most of the excerpt. I’d love the ability to hide specific class names as well as hide h1 and h2 tags entirely from displayed snippets.

    I’m happy for them to still be indexed, or not – whichever is easier, as long as they don’t display on the search result.

    I’ve been looking through this forum and the knowledge base and can find how to exclude entire posts from results, but not how to hide parts of a page from the displayed search snippet. Is this something I would control from your plugin or is it something that needs to be set at WordPress admin level?

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

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

    (@msaari)

    You can use filters. The relevanssi_pre_excerpt_content filter hooks filters the post content before the_content filters are applied, and relevanssi_excerpt_content filters the content after those filters. You can add a filtering function on one of these hooks to remove the unwanted parts of the post.

    If the content is something you don’t really want to include in the index either, you can then use the same function on relevanssi_post_content to exclude the content from being indexed, as the parameters are the same.

    There are two parameters for all of these filter hooks: the first one is the post content as a string, and the second one is the complete post object. You need to return a string containing the filtered post content.

Viewing 1 replies (of 1 total)
  • The topic ‘Exclude parts of a page from search result excerpt’ is closed to new replies.