Webstick.blog logo Wordpress, Design, SEO, Speed blog

WordPress get thumbnail URL [2024] 💥

WordPress get thumbnail URL

A featured- or thumbnail image can be added to your WordPress blog posts to make them more attractive and add visual interest. If you are creating your own theme or altering an existing theme you will need to obtain the post thumbnail URL in order to use it with your custom markup. You will need to add a piece of code into your theme files. Let's take a look at how WordPress gets the thumbnail URL for a post.


Divi Ad 680px

How get the post thumbnail URL in Wordpress

To get the URL of a post thumbnail you need to add code to the theme template you are customizing. If you simply wanted to display the post thumbnail, then you could paste this code into the template you are working on, inside the WordPress loop.

echo get_the_post_thumbnail(get_the_ID(),'medium');

You will need the URL for the post thumbnail URL if you want to display it using your custom markup or to use it in another way. This code will be added to the template.

echo get_the_post_thumbnail_url(get_the_ID(),'medium');

This code displays the URL for the featured image. The code can be customized to display the URL of the featured image. You can also change the size of your image. You will need to replace the word "medium" with another image size such as a "thumbnail","medium large", "large" or "full". You can also use any other image sizes that you have created. If you use a custom size image, make sure to regenerate thumbnails.


Divi Ad 680px

Scroll up