Sometimes, theme visual structure requires usage of featured image in obligatory way. However, website owners not necessarily will use featured image per each post and each page. If not, visual balance of the theme post or page might be just broken. And in this case the replacement with some default image might be really handy. On the screenshot above you see a featured image which is in fact a default placeholder and same image will appear on any post each time if featured image is not used. It is very easy to achieve such alternation. We shall use just WordPress conditional tag for featured image + we place the default image into “images” folder” of our theme files.
So, here we go:
<?php if (has_post_thumbnail()) : ?>
<?php the_post_thumbnail('full'); ?>
<?php else: ?>
<img src="<?php print IMAGES; ?>/images/default.jpg" alt="" />
<?php endif; ?>
If a website user, working on post or page, inserts a “featured image” it will be shown in the post (or on page). Otherwise the default image (default.jpg—as demonstrated in the code above) which is located in “images” folder will be displayed as an alternative to the Featured Image.