How to get the post thumbnail URL in WordPress

how to get the post thumbnail URL in WordPress. we use the_post_thumbnail(); function to display post thumbnail. But unfortunately there is no direct function in WordPress to get post thumbnail image url. So we use two functions ( get_post_thumbnail_id(), wp_get_attachment_image_src() ) here to get image URL of post.

 

We Used Two functions :
1.

 

this will return post thumbnail id, and $post_id is optional If post id is null, the current post will be used.

2.

 

this function will return the array with values corresponding to the (0) url, (1) width, (2) height, and (3) scale of an image attachment.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face – we are here to solve your problems.

I, Dayanand Saini,the founder and chief editor of www.webtechsource.com,have been working as a software engineer from last 4+ years. It's my hobby to learn new things and implement on live environment.

One Reply to “How to get the post thumbnail URL in WordPress”

Leave a Reply

Your email address will not be published. Required fields are marked *

28 − = 25

%d bloggers like this: