Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using wordpress 3.4.1. I need to display the featured image of a page. How can i get the featured image url by particular page id. Any help?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Did you try anything? Its always helpful to share what you have tried.

$url = wp_get_attachment_url( get_post_thumbnail_id($post_id) );

Or if you want to get the image by image size.

$src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'thumbnail_size' );
$url = $src[0];

http://codex.wordpress.org/Function_Reference/get_post_thumbnail_id

http://codex.wordpress.org/Function_Reference/wp_get_attachment_url

http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src

share|improve this answer
    
It works. Thanks –  Sam Hanson Dec 22 '12 at 7:59
    
Actually, this is wrong - it suggests that you can get pass the size as a parameter, but that's not accurate. Neither function accepts a parameter. –  cale_b Jun 20 at 3:35
    
@cale_b: Thanks for pointing out. Fixed. –  Sisir Jun 20 at 10:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.