Add Default Featured Image in WordPress Post

In WordPress single post most of the time we use a featured image while we are publishing a new post. And in front-end display we show the featured image. But if no featured image hasn’t been set then in front-end the image area become blank which is a little bit awkward in terms of quality design. But you can avoid the situation by adding a default image. Learn how you can add default featured image in WordPress post.


First of all create an image which you want to use as a default featured image and save it as default_image.jpg and upload it to your teame images folder. Then go to the page you want to place this default image and search for the following code:

[php]<?php the_post_thumbnail ?>[/php]

and repalce the code with following:


<?php if ( has_post_thumbnail() ) {
} else { ?>
<img src="<?php bloginfo(‘template_directory’); ?>/images/default_image.jpg" />
<?php } ?>


In image source just we have used images folder. If you save it in a different folder then just change the directory name.

Author: mytutorialguru

Share This Post On

Submit a Comment

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