How to Set a Default Featured Image in WordPress (Easy Way)
Set a Default Featured Image in WordPress
Do you want to display a default image for your WordPress posts? You may want to have a fallback in case you forget to add one. In this article, we will share how to set a default featured image in WordPress.
Adding an alternative image will ensure that your blog posts look professional in your theme and when shared on social media, even if you forget to add a featured photo.
There are three different methods you can use to set a default featured image in WordPress:
- Method 1. Set a branded image as the fallback featured image
- Method 2. Set the first post image as the default featured image
- Method 3. Use the WordPress Default Featured Image plugin
Ready to get started? Let’s go!
Method 1: Setting up a Branded Image as a Fallback Featured Image
Sometimes you have a blog post with no images and no featured image, and you want a fallback to be displayed as the featured image for this post.
First, open the theme file where you want to add the fallback featured image. It can be any theme file like home.php, single.php, index.php, and more.
Then, in the post loop, you need to paste the following code:
This code will verify that there is a featured image assigned to your blog post. If there is one available, then that will be displayed. Otherwise, it will display default-image.jpg from the images folder of your theme.
Method 2: Setting up the First Post Image as Default Featured Image
Sometimes you may want to use the first image within the post as the featured image. Here’s how to do it automatically…
First, you need to add the following code to your theme’s function.php file:
Next, you need to open the theme file where you want to display the featured image. Simply add the following code:
Now your post will use the first image as the featured image. However, if a featured image exists, it will display that instead.
Method 3: Using the WordPress Default Featured Image Plugin
If you are not familiar with code or want to go the easy way, then you can use a WordPress plugin.
First thing you need to do is install and activate the Default Featured Image plugin. Upon activating the plugin, you need to go to Settings » Media and click on the Select Default Featured Image button.
Select an image from your computer and make sure to save the changes.
This plugin will check to see if there’s a featured image available for your post, and if so, that will be displayed. But if there is no featured image available, then your uploaded photo will be displayed instead.
We hope this article has helped you to learn how to set a default featured image in WordPress. Here are a few other WordPress tutorials you might find helpful.
Thrive Architect Review (2022) – is it worth it?
Elementor Review – How Good Is It In 2022?
How To Increase The WordPress Upload Limit On An AWS Lightsail Bitnami Installation
Terraform vs CloudFormation: Comparing The Two Infrastructure As Code Offerings (2022)