Set default the_post_thumbnail

Adding this code snippet to your wordpress loop will check if a post thumbnail exists and if not display a default image named img-default.png.

 

 

<?php
if(has_post_thumbnail()) {
the_post_thumbnail();
} else {
echo '<img src="'.get_bloginfo("template_url").'/images/img-default.png" />';
}
?>

Be Sociable, Share!

Leave a comment