Wordpress Tutorial: Setting Fallback image for post thumbnails
Do you need to have a default fallback image displayed in your WordPress posts to give it that aesthetic appeal?
This article is for you. All you need to do is follow our guidelines and you should be able to do it in no time.
Why do you need a Fallback image for your WordPress posts?
A fallback image is a useful feature that helps you connect images with your posts or articles in WordPress. This image is resident on your homepage. We will use the terms 'fallback image’ or 'featured images’ interchangeably throughout this article as they basically mean the same thing.
To find out if your current theme supports fallback or featured images, create a new post and check if you can see a metadata box named 'featured images’ at the right-hand side of your screen.
Here is a sample:
How to add a Default Fallback image:
This is the simplest method and works for most WordPress users with compatible themes.
Go to your metadata box called 'set featured images’ and click on it. It should open an
uploading page for WordPress media.You should see something like this:
Search for a suitable image and click upload, or simply choose an image from your media
library.Bear in mind that the image will be displayed a bit differently from how it looks normally in your media library, depending on your current theme.
After setting the image you should see something like this:
For Themes that do not support featured images:
- If you did a check on your theme’s metadata box and could not find the support for featured
images, do not despair as there is a way to manually add support. - This however will involve using some simple lines of code, which of course would be provided in this tutorial.
- To manually set featured images support, copy and past this code into the functions.php file of your current theme:
add_theme_support( 'post-thumbnails');
This should enable featured images support for your posts henceforth on your current theme. To check if support has been enabled, go to your posts and check for the metadata box named 'featured images’ at the right-hand side of your screen.
This code will enable featured images support for all your posts and pages, but any featured
image you add doesn’t get automatically displayed in WordPress. To enable this, you will need to add this line of code to your templates to indicate where you want your images displayed:
<?phpthe_post_thumbnail(); ?>
- Now that is all set up you may also want to tweak your settings, say to edit image size for
your specific theme. Use this line of code in your functions.php file:
set_post_thumbnail_size( 50, 50);
This will set both the width and height of the image as 50 pixels. You can edit the numbers to any desired size to fit your page.
This Tutorial has now taught you the basics of adding fallback or featured images to your WordPress themes whether your theme supports it or not.
Happy blogging!
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Hey @davcps I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x