Title: wp_get_attachment_image Error
Last modified: August 19, 2016

---

# wp_get_attachment_image Error

 *  [calebo](https://wordpress.org/support/users/calebo/)
 * (@calebo)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/wp_get_attachment_image-error/)
 * Hi,
 * I’m currently using the below code to retrieve all images in a gallery that’s
   related to a post, but at the moment, it only retrieves 5 of the images rather
   than all of the images, i’m not sure why as there’s no where i can see it’s setting
   the limit to 5 only.
 *     ```
       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
   
       		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
       				<?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
       				<table>
       				<tr>
                       <?php
                       function recall($data)
                       {
                          $GLOBALS['d'] = $data;
                          return '';
                       }
                       ob_start("recall");
                       the_id();
                       ob_end_clean();
   
                       $args = array(
                          'order'          => 'ASC',
                          'post_type'      => 'attachment',
                          'post_parent'    => $GLOBALS['d'],
                          'post_mime_type' => 'image',
                          'post_status'    => null,
                       );
                       $attachments = get_posts($args);
   
                       if ($attachments) {
                          foreach ($attachments as $attachment) {
                             $imageTitle = $attachment->post_title;
                             $imageDescription = $attachment->post_content;
                          ?>
                          <td valign="top">
                              <p><?php echo wp_get_attachment_image($attachment->ID, 'large', false); ?></p>
                              <h4><em><?php echo $imageTitle; ?></em></h4>
                              <p><?php echo $imageDescription; ?></p>
                          <?php } ?>
                          </td>
                       <?php } ?>
                       </tr>
                       </table>
       		</div>
   
       	<?php endwhile; else: ?>
       ```
   

The topic ‘wp_get_attachment_image Error’ is closed to new replies.

## Tags

 * [display](https://wordpress.org/support/topic-tag/display/)
 * [entry](https://wordpress.org/support/topic-tag/entry/)
 * [gallery](https://wordpress.org/support/topic-tag/gallery/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [calebo](https://wordpress.org/support/users/calebo/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/wp_get_attachment_image-error/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
