How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?

Get the Image does what you need and better. It’s NOT overwhelming with lots of unnecessary features, and does what it says. Try it to see if it does what you need.

How does Get the Image plugin pull images?

  • Looks for an image by custom field (one of your choosing).

  • If no image is added by custom field, check for an image using the_post_thumbnail() (WP 2.9’s new image feature).

  • If no image is found, it grabs an image attached to your post.

  • If no image is attached, it can extract an image from your post content (off by default).

  • If no image is found at this point, it will default to an image you set (not set by default).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)