Wordpress - show featured image with post or a default image if no image set


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php if(has_post_thumbnail()) {
  2.  
  3. the_post_thumbnail();
  4.  
  5. } else {
  6.  
  7. ?>
  8.  
  9. <img width="100" height="100" src="placeholder100.jpg" alt="" border="0" />
  10.  
  11. <?php
  12. }
  13. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.