• Resolved meg28

    (@meg28)


    Hello!
    I am using your WordPress plugin for search and it makes a list of pages/posts that contain searched word. Below title it shows content with bolded word from search. But why are in the list also posts that don’t contain that word? Text below title is also without any bold word. That word is also nowhere inside its html so I’m confused. When I deactivate Relevanssi plugin, WordPress still shows those posts without searched word. What do you think it’s problem here, why are those posts showing?

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

    (@msaari)

    You can look at the posts with the Relevanssi debugger (Settings > Relevanssi > Debugging). That’ll tell you how Relevanssi sees the posts. Does the word appear somewhere in the post? Perhaps the search term appears in custom fields or some other non-visible part of the post.

    Thread Starter meg28

    (@meg28)

    Search term and some other words that are not visible on frontend appear in debugger when I put ID of that post. I’ve found it in html of editor inside h1 tag…it disappeared now randomly…Is there a way I can exclude some parts of web to be searched by certain class or something similar?

    Plugin Author Mikko Saari

    (@msaari)

    There are plenty of ways to deal with this. The most flexible way is using the relevanssi_post_content filter hook, which you can use to modify the post content before Relevanssi sees it.

    The easiest way is to give the unwanted blocks the CSS class relevanssi_noindex. If Relevanssi sees a block with this class, it is not indexed. This only works if you use the block editor, it does not work in the classic editor.

    Thread Starter meg28

    (@meg28)

    I am using Elementor as editor. I tried to add class relevanssi_noindex to unwanted section, but it’s not working. Can you give me an example of code how would I add class relevanssi_noindex to elements that have certain class name? I’m new with these filters and hooks so I’m not sure how to do it.

    Plugin Author Mikko Saari

    (@msaari)

    Unfortunately, it does not work in Elementor, either. Using relevanssi_noindex only works with the Gutenberg Block editor.

    With Elementor, the best way to remove unwanted parts of the page is using the relevanssi_post_content hook. See “Avoid indexing menus” on Divi knowledge base page for an example of how to do this. That’s with Divi, not Elementor, but the method is similar, and with Elementor, you might be able to cleanly pluck out shortcodes.

    If you want more help with this, please provide me with an example of page source (as it appears in the wp_posts database table) and tell me which elements you’d like to exclude.

    Thread Starter meg28

    (@meg28)

    I have just looked inside wp_posts database table and the problem is that I created one post as I wanted to and cloned that same one for at least 100 times and now all of those posts have same post_content although they are completely different since I edited each of them inside Elementor. Is there a way plugin can search only Elementor elements since they are obviously not stored in wp_posts database table?

    Plugin Author Mikko Saari

    (@msaari)

    Is the post-specific content stored in the custom fields, then? Or where does Elementor store the content that is unique to the post?

    Relevanssi sees the post content and custom fields, so the content pretty much must be in one of these, otherwise it would be completely invisible to Relevanssi.

    If the Elementor content is in the custom fields, then the solution is to use the relevanssi_custom_field_value to weed out the unwanted parts.

    Thread Starter meg28

    (@meg28)

    Hi, sorry for not replying for a long time. Elementor stores content in wp_postmeta table with metakey _elementor_data and post_id. So I guess neither Relevanssi nor native WordPress search won’t work properly?

    Plugin Author Mikko Saari

    (@msaari)

    Just make Relevanssi index the _elementor_data custom field, reindex and you should be fine.

    Thread Starter meg28

    (@meg28)

    The problem still persists since Relevanssi will also look in wp_posts table where the content is wrong…Is there a way I can make it search only by _elementor_data and title?

    Plugin Author Mikko Saari

    (@msaari)

    Thread Starter meg28

    (@meg28)

    Thank you very much, it’s working now!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Search showing posts that don’t contain searched word’ is closed to new replies.