Search results excerpt

Hi there

Further to the post I did regarding a custom search results page in Pro, I was kindly aided by you in setting up the page (this was the topic - Custom Search Results Using Layout Builder - Support - Themeco Forum)

However, I’ve just noted that the ‘excerpt’ part of the query that comes up when the page is searched doesn’t show key words that it’s found on the page, nor even the standard excerpt for the page, it just shows the various bits of text at the top of each page in quite a jumble.

Is there any way to get the excerpt part of the looper to actually show either the relevant parts of the text it’s pulled from the query search, or even as a basic alternative, a tidier version of the page excerpt properly formatted?

The website to which I refer is https://staging3.rachel-ashcroft.co.uk/

I’d appreciate any support or assistance you could provide.

Many thanks

Hi James,

You can use The Excerpt element inside the looper to show the excerpt value for the specific posts, and then you can attach the layout to the Search Result page.

Hope it helps.
Thanks

Hi there,

Yes I have included the excerpt as part of the search results layout page I’ve created already. But the excerpts are muddled jumbles of wording that doesn’t actually reference the search made on the pages it gives in the results. It just shows a unformated jumble of words found (presumably at the top) of the page. See screenshot.

Is there anyway to make the excerpt actually show the words it’s finding in the page (like Google would) or at least format the content of the page it’s pulling through correctly? Perhaps have a custom except for the page even, if amending what it pulls through isn’t possible?

Many thanks

Hi James,

The Search Results displays excerpts and WordPress generates the plain text while displaying excerpt, and it removes all shortcodes and HTML tags. And that might be the reason behind your issue.
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, which help you on this: https://www.wpbeginner.com/plugins/add-excerpts-to-your-pages-in-wordpress/

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. Please Scroll down and find the Excerpt meta box section and there, add your text excerpt.

Hopefully, it will solve your issue.

Thanks

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