Advertisement
elbatron

all image from post without thumbs and max number

Dec 11th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <?php
  2. $image_count = 0;
  3. $max_images = 10;  //set this to the max number of images you want.
  4. $ids = get_posts( array( 'post_type' => 'post', 'posts_per_page' => -1 ,'fields' =>'ids') );
  5. if (count($ids) > 0){
  6.     foreach ($ids as $ids){
  7.         while ($image_count < $max_images){
  8.             $args = array(
  9.                 'post_type'   => 'attachment',
  10.                 'numberposts' => -1,
  11.                 'post_status' => null,
  12.                 'post_parent' => $id,
  13.                 'exclude'     => get_post_thumbnail_id($id)
  14.             );
  15.             $attachments = get_posts( $args );
  16.             if ( $attachments ) {
  17.                 foreach ( $attachments as $attachment ) {
  18.                     while ($image_count < $max_images){
  19.                         echo '<dl class="gallery-item">
  20.                            <dt class="gallery-icon">
  21.                                <a rel="shadowbox[sbalbum-1];player=img;" href="' . get_permalink($attachment->ID) . '">'. wp_get_attachment_image( $attachment->ID, 'footer_thumbs' )  . '</a>
  22.                            </dt>
  23.                         </dl>';
  24.                          $image_count = $image_count + 1;
  25.                     }
  26.                 }
  27.             }
  28.         }
  29.     }
  30. }                  
  31. ?>
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement