When you are working with WordPress theme or Plugin sometimes you may need to retrieve The Post Thumbnail URL.  Actually it is pretty easy. You simply need to use following code snippet to Get Post Thumbnail URL in WordPress:

<?php
$thumbnail_id = get_post_thumbnail_id();
$thumbnail_url = wp_get_attachment_image_src($thumbnail_id,'thumbnail-size', true);
echo $thumbnail_url[0];
?>

But in the above code snippet you need to remove thumbnail-size with the whatever image size you want to get. Default image size are full, large, medium & thumbnail. So when you want to original image url, replace thumbnail-size in code with full.


Post Tags


About The Author


Discussion

Leave a Reply

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

home