Rob Bennet Interactive

  • Archive
  • RSS
  • Have a Question?
  • Submit

WordPress - get post thumbnail URL only

I had a need to ONLY return the post thumbnail (featured image) URL without being wrapped in an image tag.  I was going to use it as a bgimage so I could overlay some stuff.  Figured it out by returning it as an object, seems to work pretty well:

$thumbnail = new SimpleXMLElement( get_the_post_thumbnail( $postid ) );
print $thumbnail->attributes()->src;
  • 7 months ago
  • Permalink
  • Share
    Tweet
← Previous • Next →

About

@rwbennet
  • RSS
  • Random
  • Archive
  • Have a Question?
  • Submit
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr