Last Updated: February 25, 2016
·
1.142K
· pimschaaf

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);
}

1 Response
Add your 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 ·