Okay, so if you’re running a WordPress site and you’ve ever been like, “I need to make sure my posts don’t look bare without a featured image,” this one’s for you. It’s super simple to set up a default image for posts that don’t have one. You can either use a plugin or add some code. Here’s how:
Option 1: The Plugin Way
You know how plugins can make life easier? Yeah, that’s definitely the case here.
- First, install and activate the Default Featured Image plugin. Just head to the WordPress plugin repository and search for it.
- After it’s installed, go to Settings > Default Featured Image.
- Upload your default image. It can be anything you like. It’ll be the go-to whenever a post doesn’t have a featured image.
- Hit save.
That’s it. Now your posts won’t be looking naked without an image.
Option 2: The Code Method (For the Code Lovers)
Okay, if you’re more into doing things the custom way and don’t mind adding a bit of code, here’s a quick method:
- Upload your default image to the Media Library and grab the image URL.
- Now go to Appearance > Theme Editor and open the functions.php file.
- At the bottom of the file, add this little snippet of code:
function set_default_featured_image($post_id) {
if (!has_post_thumbnail($post_id)) {
$default_image = 'YOUR_IMAGE_URL'; // Replace with your image URL
set_post_thumbnail($post_id, $default_image);
}
}
add_action('save_post', 'set_default_featured_image');
- Don’t forget to replace
'YOUR_IMAGE_URL'
with the URL you copied earlier. - Save it.
From now on, whenever you post something without a featured image, WordPress will automatically set the default one for you.