WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two images attached to a page. One is being used as the featured image, and I want the other to automatically be displayed at the designated spot in the template (within the loop) at full size. The image I want is the first image attachment, so as I understand, I should be able to simply use:

<?php echo wp_get_attachment_image(1, 'full'); ?> 

But, this is returning nothing. What am I missing?

share|improve this question
Is the 1 an example ID, or are you trying to use 1 as the attachment ID(i very much doubt there's an attachment with that ID). – t31os Mar 10 '11 at 14:26

Don't you need to use get_posts( 'post_type=attachment' ) to return the attachment IDs? So, something like:

$args = array( 
     'post_type' => 'attachment', 
     'numberposts' => -1, 
     'post_status' => null, 
     'post_parent' => $post->ID 
$attachments = get_posts( $args );
$myimageid = $attachments[0]->ID;

wp_get_attachment_image( $myimageid, 'full' );

Otherwise, you're using $post->ID of 1, which isn't likely to work.

share|improve this answer
ID of 1 is guaranteed to fail, since the default installation post has that ID number no matter what. – John P Bloch Apr 8 '11 at 20:11

Your Answer


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.