In this example:

Ajax Load More will infinite scroll a gallery of images attached to a specific WordPress post.


<div class="attachment">
  <?php 
  global $post; 
  $page_id = get_queried_object_id();
  $post_thumbnail_id = get_post_thumbnail_id( $page_id );
  $image = wp_get_attachment_image_src( $post_thumbnail_id, 'thumbnail-large' );
  ?>
  <img src="<?php echo $image[0]; ?>" alt="" />
</div>
PHP

The following shortcode was used to create the Attachments example.

[ajax_load_more post_type="attachment" custom_args="post_parent:20011" post_status="inherit" preloaded="true"]

Note: When querying attachments by Post ID you must always define a post_parent ID and set post_status=”inherit” in the shortcode.

The following Repeater Template was used to create the Attachments example.