WordPress post thumbnail url
Easy access to the WordPress post thumbnail URL.
function get_the_post_thumbnail_url($post_id, $size = 'thumbnail')
{
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), $size );
return $src[0];
}
function the_post_thumbnail_url($post_id, $size = 'thumbnail')
{
echo get_the_post_thumbnail_url($post_id, $size);
}
Written by pimschaaf
Related protips
1 Response
Added default value for size
to make it optional like wp_get_attachment_image_src()
.
Should support wp_get_attachment_image_src
icon
parameter too.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#