Get wordpress post thumbnail src

0.67K views
no comments
25 Oct 2014 2:25 pm

In some where we need only thumbnail source link the function the_post_thumbnail cannot return  thumbnail source link, we ca two ways to get thumbnail src.

1. wp_get_attachment_thumb_url

$post_id = get_the_ID();
$size = 'thumbnail';
$thumb_src = wp_get_attachment_thumb_url(get_post_thumbnail_id($post_id),$size);
echo '<img src="'.$thumb_src.'" />';

2. get_attachment_src

$post_id = get_the_ID();
$size = 'thumbnail';
$thumb_arraydata = wp_get_attachment_image_src(get_post_thumbnail_id($post_id),$size);
$thumb_src = $thumb_arraydata['0'];
echo '<img src="'.$thumb_src.'" />';

NOTE:Your Email Address will be not shown and please do not add spamming comments because here is REL="NOFOLLOW" on your links and comments also moderated shown.
<code>Put html css or any language code under this tag</code>