Search results page layout

Hello again, I would like to have a search results page as you have in the demo but instead I get a “paragraph” text only (no title of the post as I have removed the post title to show in post).
I am not using featured image for the post but I am using images in the content, is there a way to display an image from the content instead?

For result I would like to get the post title only, with an image from the content…Can you help me build that in my child theme? I would be really thankfull :slight_smile:

My testing site is www.getaway24.ru

Hi @codeoner,

I hope you are well today and thank you for your question.

You can display post title on that page by adding the following CSS code in the Custom CSS option of your theme on the below path.

Admin Area -> Appearance -> Customize -> Additional CSS

.search-results .entry-header {
display: block;
}

Only featured images display on that page so you can set images from the post content as featured image by using below solutions.

Best Regards,
Movin

hm… this will not help as what I need is not to set a featured image but I would like to change the layout of the page (remove excerpt, read more button, change img size etc.) and make it show an image from the post content.
Which files do I have to change?
I checked search.php which guided me to template-parts/content.php and there I found this lines

if ( is_page_template( 'page-fullwidth.php' ) ) {
					the_post_thumbnail( 'sparkling-featured-fullwidth', array(
						'class' => 'single-featured',
					) );
				} else {                    the_post_thumbnail( 'sparkling-featured', array(
					'class' => 'single-featured',
				) );
				}

I think I have to touch something in there to make the content img display ?
I use a plugin which already shows in a galery images from the content and after searching I think there is a function which does that

if ( strpos( $template, '%featured_image_src%' ) !== false ) {
            $tags['%featured_image_src%'] = $this->get_first_image( $post, 'full' );
        }

But I havent managed to connect theese two.
Also I am sure that If I change it there (content.php) it will change in all pages and not only in search results, so should I make a new file in my child theme?

the code for the page title works fine though!

Just copy the file template-parts/content.php in your child theme and rename it to template-parts/content-search.php then you can edit it however you want as it will only affect search results page.

thanks movin :slight_smile:

You are most welcome here :slight_smile: