echo placeholder image if post thumbnail not found

118

<?php if ( has_post_thumbnail()) {
  the_post_thumbnail($post->ID);
  } else { ?>
  <img class="post-placeholder-img" src="https://via.placeholder.com/300" alt="<?php the_title(); ?>" />
<?php } ?>

Comments

Submit
0 Comments