Advertisement
all2aller

Gallery Loop (attachment)

Aug 13th, 2015
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. <div class="gallery-slider">
  2.    <?php
  3.       $attachments = get_posts( array(
  4.          'post_type' => 'attachment',
  5.          'post_mime_type' => 'image',
  6.          'posts_per_page' => -1,
  7.          'post_parent' => $post->ID
  8.                                                
  9.       ) );
  10.       ?>
  11.    <ul class="slides">
  12.       <?php if ( $attachments ) {
  13.          foreach ( $attachments as $attachment ) {
  14.          
  15.             $thumbimg = wp_get_attachment_image( $attachment->ID, 'exhibition_img', true );
  16.             $thumbimg_url = wp_get_attachment_url( $attachment->ID, '', false );
  17.                                          
  18.          echo '<li><a href="'.$thumbimg_url.'">' . $thumbimg . '</a></li>';    
  19.          }
  20.                                        
  21.          
  22.                                          
  23.          }
  24.          ?>
  25.    </ul>
  26. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement