WordPress Hosting Coupon Code | 3 Months | 100% OFF Get Offer

Get WordPress Post Featured Image URL & Post Thumbnail

Moeez — December 8, 2017 2 Minutes Read

In many cases, developers need the direct URL of a featured image. A probable scenario that requires this could be when the featured image is used as a header or the post background image. In such a case, the requirement is more than just outputting the featured image in the HTML.

To get the URL, place the following snippet in the files including post.php, single.php, template.php:

To get the post id (for $post->ID), check the URL of the post. Check out the following screenshot for more detail:

To style the featured image, I recommend the following CSS snippet:

Get Single Post Thumbnail

In many cases, post thumbnail is the feature of the theme and not part of the core WordPress capabilities. To enable the support for the featured image at post and pages, use the following snippet. Although this snippet will enable the support, it will not display it in the installed themes.

In the above example, the snippet is enabled at single.php.


In this article, I have discusses how to get WordPress featured image URL and post thumbnail on a single page. If you need help with the code, do leave a comment below

Subscribe to Get a FREE WordPress Ebook Right in Your Inbox

WPblog provides the complete guide to launch your WordPress website completely FREE!

Moeez is ‘The’ blogger in charge of WPblog. He loves to interact and learn about WordPress with people in the WordPress community. Outside his work life, Moeez spends time hanging out with his friends, playing Xbox and watching football on the weekends. You can get in touch with him at moeez[at]wpblog.com.