Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get post thumbnail using post id in wordpress?

I am trying to get the post thumbnail using post_id,but i am getting so many problems.

Iam calling the function in a separate php file in theme directory

echo get_the_post_thumbnail('637');

Fatal error: Call to undefined function get_the_post_thumbnail() in ...

1)can we get the thumbnail using post_id

or

2)can we get the image source using post_id

please any body help me

Thanks in advance

like image 398
Manju Avatar asked Feb 13 '14 12:02

Manju


1 Answers

Try this

global $post;
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'post'); 
echo $thumb[0];
like image 133
brunomarks7 Avatar answered Oct 05 '22 02:10

brunomarks7