How to Show Featured Images in WordPress Posts to Boost Engagement

Want to make your blog posts pop with eye-catching featured images?

You‘re not alone – over 58% of bloggers say imagery is vital for driving shares and subscriptions.

But if you‘re struggling to control image output in WordPress, don‘t lose hope! Many themes require tweaking before displaying photos reliably.

In this 2,800+ word guide, you‘ll get a beginner-friendly action plan for finally showing off post images to boost clicks.

Here‘s what I‘ll cover:

  • The power of great featured images
  • Displaying default WordPress image sizes
  • Modifying theme template files
  • Configuring image alignment/styling
  • Filtering image posts with queries
  • Optimizing speed with image compression
  • Using plugins to automate display
  • Recap and final thoughts

Let‘s dive in!

The Power of Featured Images

Before digging into code, I want to share some motivation…

Compelling featured images make your content more attractive and memorable for several reasons:

Images Break Up Walls of Text

Blocks of dense text are difficult to digest. Images provide breathing room to reset the reader‘s eyes as they scroll through an article.

Visuals Increase Recall and Shares

According to behavioral research studies, pictorial elements boost people‘s ability to retain details and concepts. And posts with images receive 94% more total views.

Faster Communication of Complex Topics

The old saying "a picture is worth 1,000 words" rings true. Images convey what would otherwise require lengthy descriptions to paint a mental picture.

In summary – you absolutely want eye-catching featured photos on your WordPress site!

Now let‘s get into the details on displaying them properly…

Displaying Default WordPress Image Sizes

The simplest way to output a featured image is using WordPress‘s built-in the_post_thumbnail() function:

<?php 
  if (has_post_thumbnail()) {
    the_post_thumbnail(); 
  }
?>

This checks if a featured image is defined for the post, and prints out the default thumbnail size for your theme.

However, you can pass a parameter to control the exact dimensions:

the_post_thumbnail(‘large‘); // 640px max width 

The possible values are:

  • Thumbnail – 150px x 150px
  • Medium – 300px x 300px
  • Large – 640px x 640px
  • Full – Original unconstrained size

For example, here is how a medium 300px wide image looks:

[Display medium size featured image]

And here is the same image set to full size at high-resolution:

[Display large size featured image]

The fil size is great when you want crisp details, but comes with larger file downloads impacting speed.

Now let‘s explore editing WordPress theme code to enable featured image capabilities.

Modifying Theme Template Files

Many themes don‘t come with featured images activated out-of-the-box on single posts and pages.

Without template customizations, you might only see images on main blog pages…not the actual articles.

Here is how to customize your theme to unlock featured image powers:

Step 1) Identify Template File:

Scan for single.php, content-single.php, or similar. Sometimes labeled content.php or post.php.

Step 2) Backup File:

Save a copy of the original file before making changes!

Step 3) Open File & Find Content:

Look for the_content() section where the text appears.

Step 4) Add Featured Image Code:

Insert this snippet above the content:

<?php 
  if (has_post_thumbnail()) {
    the_post_thumbnail(); 
  }
?>

<?php the_content(); ?>

This checks for an image, outputs it, then displays the text content.

Step 5) Save and Test!

View a single post to confirm your shiny photo appears!

Be sure to check page load times after – optimize large images as outlined later in this guide.

Next let‘s explore layout options…

Configuring Image Alignment & Styling

The bare the_post_thumbnail() output uses your default theme styling rules.

You might want centered images, precise widths, rounded corners, or other effects.

Here are some configuration examples you can add to the image PHP snippets:

Left, Right, or Center Align

the_post_thumbnail(‘medium‘, array(
  ‘class‘ => ‘alignleft‘
));

Define Max Width

the_post_thumbnail(‘full‘, array( 
  ‘style‘ => ‘max-width: 100%;‘
));

Add Custom CSS Class Styling

the_post_thumbnail(‘full‘, array(
  ‘class‘ => ‘custom-class‘ 
));

Then in your theme‘s style.css file:

.custom-class {
  border-radius: 8px;
  padding: 10px;
} 

This separates the presentation layer from your template logic.

Now what if you only want to show posts that contain a featured image in listings? Let‘s explore…

Filtering Posts by Featured Image Presence

When displaying post excerpts, you may want to only include ones with featured images.

For example, mixing posts with and without images creates an inconsistent feed.

The following WP_Query example filters to only fetch posts with assigned featured media:

$query = new WP_Query(array(
  ‘meta_query‘ => array(
    array(
      ‘key‘ => ‘_thumbnail_id‘,
    )
  ) 
));

We query on the post meta data field _thumbnail_id to test if an image is defined.

Now you can display these filtered posts normally with the image techniques covered!

Next let‘s talk about speed…

Optimizing Images for Faster Loading

High resolution photos slow down your site – but compressed files fix that! 🚀

Here are some tips for performing featured image optimization:

  • Resize Images before uploading for crisp quality without oversized dimensions
  • Compress JPGs with TinyPNG/TinyJPG to drastically shrink sizes
  • Convert Large PNGs to JPG as the format has better compression
  • Lazy Load below-the-fold images to defer offscreen rendering
  • Set Max Widths on the_post_thumbnail() to limit file size
  • Cache rendered thumbnails via a plugin like WP Rocket

I suggest an automated tool like ShortPixel or Optimole to compress uploads with no extra effort.

The speed gains let you confidently add images without slowing down the site!

Now let‘s explore plugin options for display configuration.

Using Plugins to Display Featured Images

Hard-coding image display logic into templates gives the most control…

…but WordPress plugins offer more configurability without code changes.

Here are some top-rated tools for managing featured media:

The main downside to plugins is potential conflicts on updates. Sticking to core WordPress functions brings more future-proofing.

I suggest trying plugins first, then using raw code tweaks as a backup if you hit limitations.

Now let‘s connect everything we covered…

Final Thoughts

Wow, we covered a lot of ground! 🏁

Here‘s a quick recap of the key topics around displaying WordPress featured images:

  • Enabling images boosts engagement with visual appeal
  • Built-in WordPress functions handle default image sizes
  • Almost any theme can be edited to output images
  • Configuration tweaks help align and style images
  • Queries filter content by featured media presence
  • Compression decreases file sizes drastically
  • Plugins provide more options without code skills

The main takeaway…

With a mix of theme template modifications and speed optimization, you can make any WordPress site shine with compelling featured photos!

Now I‘d love to hear your biggest takeaway or question in the comments below!

Tags: