Adding thumbnails to blog posts in WordPress Theme
WordPress supports Post Thumbnails (also known as Featured Images) to visually represent posts, pages, or custom post types. On ruachost.com, you can enable and display thumbnails in your theme with a few simple steps.
Why Use Thumbnails?
Section titled “Why Use Thumbnails?”- Improves the look of your blog by adding visuals.
- Helps readers quickly identify posts.
- Essential for magazine‑style layouts and grid designs.
- Increases engagement and click‑through rates.
Enabling Thumbnails in Your Theme
Section titled “Enabling Thumbnails in Your Theme”-
Log in to WordPress with an administrator account.
-
In the dashboard, go to Appearance → Theme Editor.
-
Select your active theme and open the functions.php file.
-
Add the following code snippet:
// Enable featured images (post thumbnails)add_theme_support('post-thumbnails'); -
Click Update File to save changes.
✅ Your theme now supports featured images.
Displaying Thumbnails in Blog Posts
Section titled “Displaying Thumbnails in Blog Posts”-
Open the template file where you want thumbnails to appear (e.g.,
index.php,single.php, orcontent.php). -
Insert the following code inside the post loop:
<?php if (has_post_thumbnail()) {the_post_thumbnail('thumbnail'); // Options: 'thumbnail', 'medium', 'large', 'full'} ?> -
Save changes.
-
Go to Posts → Add New or edit an existing post.
-
In the editor sidebar, set a Featured Image.
✅ The thumbnail will now display with your blog posts.
⚙️ Customizing Thumbnail Sizes
Section titled “⚙️ Customizing Thumbnail Sizes”You can define custom sizes in functions.php:
// Add custom thumbnail sizeadd_image_size('custom-thumb', 300, 200, true); // width, height, cropThen call it in your template:
the_post_thumbnail('custom-thumb');Important Notes
Section titled “Important Notes”- Always back up your theme files before editing.
- Use a child theme to preserve changes during updates.
- Thumbnails may need regeneration if you change sizes (use the “Regenerate Thumbnails” plugin).
- Featured images are theme‑dependent, some themes already include support.