Get the post thumbnail URL in WordPress

// store post id in a variable
$post_id = get_the_ID();

//get image attributes like 'url', 'width' and 'height', of an image attachment file.
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'full' );

$url = $thumb['0']; // get url from array

Output of above code

    [0] => http://localhost/testword-press/wp-content/uploads/2014/26/image9.jpg
    [1] => 224
    [2] => 260
    [3] => 

2 thoughts on “Get the post thumbnail URL in WordPress”

  1. obviously like your web-site but you have to take a look at the spelling on quite a few of your posts. A number of them are rife with spelling issues and I to find it very bothersome to tell the truth on the other hand I’ll definitely come again again.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s