How to Get WordPress Post Featured Image URL

Are you a WordPress developer or an advanced WordPress user? Whoever you are, sometimes you may need the direct URL of a featured image of your posts and display it into your posts. Let’s find some easy way to get the WordPress post featured image URL.

How to Display a Featured Image

The easiest way to display the featured images in your custom theme or somewhere else is by adding the following code:

<div style="max-width: 100%"><?php the_post_thumbnail(); ?></div>

In the official documentation of the WordPress function the_post_thumbnail() right here is written as a description “Display the post thumbnail”. This function has as the first parameter size, so you can write the function with the size you need.

Default WordPress and WooCommerce image sizes


//Default WordPress
the_post_thumbnail( 'thumbnail' );    
the_post_thumbnail( 'medium' );       
the_post_thumbnail( 'medium_large' ); 
the_post_thumbnail( 'large' );         
the_post_thumbnail( 'full' );        
//With WooCommerce
the_post_thumbnail( 'shop_thumbnail' ); 
the_post_thumbnail( 'shop_catalog' );   
the_post_thumbnail( 'shop_single' );  

Get WordPress Post Featured Image URL

I suppose that you are using a newer version than WordPress 4.4 (if you not, you are crazy) you can use the built-in WordPress function the_post_thumbnail_url() function to return the URL of the featured post image.

//Replace 'medium' with another image size
the_post_thumbnail_url( 'medium' );

Proper usage of the function get_the_post_thumbnail_url() inside the loop

if ( have_posts() ) {
    while ( have_posts() ) {


        $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); 

        echo '<a href="'.esc_url($featured_img_url).'" rel="lightbox">'; 
        echo '</a>';


Feel free to write a comment with any questions.

UNLIMITED DOWNLOADS: 50+ Million Website Templates & Design Assets

All the Website Templates you need and many other design elements, are available for a monthly subscription by subscribing to Envato Elements. The subscription costs $16.50 per month and gives you unlimited access to a massive and growing library of over 50 million items that can be downloaded as often as you need (stock photos too)!

Recent Articles

How To Speed Up Your WordPress

Optimizing the speed of your WordPress website is crucial for several reasons. Not only does a fast-loading website provide a better user...

How to Hide “Add to Cart” Button in WooCommerce Quickly

Once on your project, you will maybe need to disable selling products, make a catalog from your e-commerce store, or simply hide...

Agronix – Organic Farm Agriculture WordPress Theme [Free WordPress theme download]

Demo Download Agronix – Organic Farm WordPress Theme. We are Happy to presenting you the Agronix Agriculture Farming WordPress Theme. It is very easy to customize...

Roux – Creative Portfolio WordPress Theme [Free WordPress theme download]

Demo Download This is Roux, a splash of vibrant creativity your beautiful new website needs! Roux comes with tons of creative portfolio, gallery and graphic...

Get in touch

Be our first-class reader, build a community and follow us on social media!

Leave A Reply

Please enter your comment!
Please enter your name here