Search results displays unwanted page

I just noticed that search queries on my website include some unwanted results, for example, when I search “blueberry” (an ingredient that appears in some recipes), one of the search results is the page “Recipes”, displaying an excerpt that includes CSS and shortcodes, it really looks quite bad. How can I fix this? Screenshot below.

Hi @muriel,

Thanks for reaching out.
The search results display excerpts. And WordPress generates plain text when displaying the excerpt, it will remove all shortcodes and HTML. But some could bypass if it contains malformed content, or other 3rd party plugins are appending some content.
The solution is adding text excerpt manually into your page(s).
And since pages, do not have excerpts by default, you will have to add custom codes into WordPress to be able to insert a page excerpt.
Please go through this link to guide you to do it:

Please follow the steps:

  1. Add this line to your child theme’s functions.php which adds the excerpt option to your pages.

    add_post_type_support( 'page', 'excerpt' );

  2. Edit your page or post and scroll to the very top and click Screen Options, make sure the Excerpt toggled is on
    Scroll down and find the Excerpt meta box section and there, add your text excerpt.

Hopefully, it will solve your issue.

Thanks

That works perfectly, thank you!!

You’re welcome!
We’re glad we were able to help you out.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.