Adding thumbnail to search results & changing content.php

Looking to discover how to alter my content.php code to add the thumbnail image of the specific posts to my search results located here for example:

https://divesummit.com/?s=suuntosubmit=Search

I would like a thumbnail of the featured post’s image listed along with the smaller blurb of the post in the search results.

    ?php get_template_part( 'content', get_post_format() ); ?

by somehow changing content.php I can have it include a small thumbnail along with each search result. My theme already has thumb support I just need help implementing it.

Any help on doing this would be appreciated.

PS. I do have a child theme installed

Topic thumbnails Wordpress search

Category Web


Modifying content.php is a possible way to go.

Start by finding the right place to insert lines similar to this:

if (is_search()) {
    the_post_thumbnail();
}

The function the_post_thumbnail() will output the image selected as featured image upon editing the post. is_search() limits this output to when showing search results.


Use the_post_thumbnail. For example:

<?php if ( has_post_thumbnail()) : ?>
   <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
   <?php the_post_thumbnail(); ?>
   </a>
<?php endif; ?>

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.