Search page results modification

Hi,

I read on another topic a that I found a couple of days ago that you could change the search results page aesthetics and data that it returns. Currently on my site if your perform a search, the results just return page / post titles and there is a large gap between them and visually it doesn’t look very good and also it doesn’t give you any clue as to the content. I would like to have at least some part of the text from the page or post below these titles and for them to be closer together.

Also maybe a title at the top of the page saying: Search results for: online (whatever you have searched for)

My site results: https://hadleylearningcommunity.org.uk/secondary/?s=online

I have been looking at https://www.relevanssi.com/?s=pdf which is close to what i want. Any ideas folks?

Thanks again.

Hi,

  1. To make it closer, you can add the code below in Theme Options > CSS
.search-results .hentry {
    margin-top: 20px;
}
  1. Pages by default does not include excerpt. To enable it, please add the code below in your child theme’s functions.php file.
add_post_type_support( 'page', 'excerpt' );

After adding that code, you will be able to add your excerpt here.

Hope that helps

Thanks @paul.r I will give that a try. Just curious, besides the excerpt, could it actually pull the first x mount of character off the text content on the page or post itself or? Thanks again.

Hi Chris,

When Wordpress automatically generate excerpts, it removes HTML, scripts, shortcodes or any codes just to pull a plain text excerpt. And with the builder, that is where shortcodes are coming from so if you build your post in it (cornerstone or any builder) then it will generate shortcodes. It will then only use the usable texts after the removable of all codes (some texts belong to shortcode blocks and they will be removed too), hence, you may see different text than what you really built.

For this reason, manually adding excerpt is the recommendation.

Cheers!

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