Bobcares

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL

*The maximum is $4000 in credits, Offer valid till November 30th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL

*The maximum is $4000 in credits, Offer valid till November 30th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

Default fallback image for WordPress post thumbnails | How To?

by | Oct 26, 2022

How to set the default fallback image for WordPress post thumbnails? Let’s use this article to find a solution. As part of our WordPress Support Services, Bobcares provides answers to WordPress-related questions.

How to set the default fallback image for WordPress post thumbnails?

Post thumbnails, often known as featured pictures, are a WordPress theme feature that allows users to link an image to a blog post or article. This image is then placed on the homepage, archives, or sidebar widgets, depending on the theme. If we forget to add one, then the article will appear without the image. Hence the layout will look broken.

The default fallback image prevents such situations and it will be used when no post thumbnail is found. Let’s look at how to easily configure a default fallback image for WordPress post thumbnails.

Solution 1

  1. Firstly, download and install the WordPress Default Featured Image plugin.
  2. Go to the Settings » Media page to customize the plugin settings.
  3. Click the ‘Select default featured image’ option on the new page to upload or select the image we want to use as the fallback post thumbnail.
  4. Click on the Save changes button.
  5. Finally, we can visit the website to see it in action.

Solution 2

In this method, we are using codes on the WordPress theme files. The following are the steps to set the default fallback image for WordPress post thumbnails:

  1. Firstly, create an image that we need to use as the default image.
  2. Then upload it to the WordPress theme’s images folder using any FTP client. The images folder for the theme is placed in the /wp-content/themes/yur-theme/ folder. If it does not have an images folder, we must create one.
  3. When a post does not have its own post thumbnail, tell WordPress to look for this image. Post thumbnails are displayed in many locations across the WordPress theme. In the theme files, check for the_post_thumbnail() method. It’s usually found in archive.php, single.php, or content templates.

    Next, include the below code where we want to display the thumbnail.

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

    src=”<?php bloginfo(‘template_directory’); ?>/images/default-image.jpg”alt=”<?

    php the_title(); ?>”/><?php } ?>

  4. Also, replace default-image.jpg with our own image file name.
  5. Finally, we can visit the website to see it in action.

[Searching a solution for a different WordPress issue? We’re here to assist.]

Conclusion

To summarize, we have included two solutions from our Tech team to set up the default fallback image for WordPress post thumbnails.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.