No featured images in search results

In the search results there are no featured images. Why?
I also need 4 search results in each row.
Thanks

my website: http://www.reggiadicasertaunofficial.it/it/?s=carlo

Hello there,

It’s intentionally designed like so. No issue to resolve. But, it doesn’t meet your requirement. In order to display the featured image on search result, you’ll need to edit the content-search.php file in the child theme mode. Then put this code block after the article tag opening (near the top line) to call the featured image:


<?php if ( has_post_thumbnail() && ( get_theme_mod( 'index_feat_image' ) != 1 ) ) : ?>
	<div class="entry-thumb">
		<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('sydney-large-thumb'); ?></a>
	</div>
<?php endif; ?>

So you’ll have something like this:


<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<?php if ( has_post_thumbnail() && ( get_theme_mod( 'index_feat_image' ) != 1 ) ) : ?>
	<div class="entry-thumb">
		<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('sydney-large-thumb'); ?></a>
	</div>
<?php endif; ?>

To make easy to start working with a child theme, I’d recommend you use our premade child theme which can be downloaded from this link.

Regards,
Kharis

thanks. There is a way to show 3 results for each row?And to customize the post titles?
Because I have another website that is just a gallery, and i can’t set any featured images, so the search results page shows just links. How to fix this? With other themes I never had these problems. Thanks

Hello there,

By default, the maximum of posts displayed in search result page follows the limitation number defined in the Settings > Reading > Blog pages show at most. You can set different limitation number in the search result page by adding the below custom function.


function sydney_child_modify_search_result_query( $query ) {

    if ( !is_admin() && is_search() && $query->is_main_query() ) {
		
	// Limit number of items per page 
	$limit = 2;
        $query->set( 'posts_per_page', $limit );

    }
    
    return;
    
}
add_action( 'pre_get_posts', 'sydney_child_modify_search_result_query', 1 );

Add the code above into your child theme’s functions.php file or use functionality plugin like Code Snippets without child theme.

Regards,
Kharis

I don’t need to set the maximum number of results, I need this:

  1. the results should be showed 3 per row and not 1 per row as it shows now
  2. how can show the attachment image instead of the featured one?
    3)how I can customize the title font size?

Thanks a lot

Hello there,

> 1

Please add this custom CSS code into Appearance > Customize > Additional CSS in your site dashboard.


@media only screen and (min-width:781px) {
  
  .entry-wrapper {
    display: flex;
    flex-wrap: wrap;
  }
  
  .entry-wrapper .hentry {
    display: flex;
    flex-direction: column;
    width: 33.333333333333333%;
    padding-left: 20px; 
    padding-right: 20px;    
  }  
  
  .content-area .entry-wrapper .hentry:after {  
    left: 20px;
  }  
  
  .content-area .entry-wrapper .hentry:first-child {
    padding-top: 50px;
  }
  
  .content-area .entry-wrapper .hentry:first-child:after {
    height: 1px;
  }  
  
}

> 2

I am sorry there is no way to do that

> 3

You can use this CSS code:


.search .hentry .title-post {
  font-size: 16px;  
} 

Regards,
Kharis

it doesn’t works sorry

Hello there,

Do you have other custom CSS code priors the new ones I suggested? If so, please make sure your group of CSS code is error free. The easiest way to check is to go to this tool and then validate your code.

Regards,
Kharis