Last Updated: February 25, 2016
·
1.544K
· 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 ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside