Advertisement
Guest User

query images from post category

a guest
Aug 8th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php query_posts( array( 'category__and' => array(1), 'posts_per_page' => 3, 'orderby' => 'title', 'order' => 'DESC' ) );
  2.  
  3. while ( have_posts() ) : the_post(); ?>
  4.  
  5. <?php
  6. $args = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'post_parent' => $post->ID );
  7. $images = get_posts($args);
  8.     if ($images) {
  9.     foreach ( $images as $image ) { ?>
  10.       <a href="<?php echo wp_get_attachment_url( $image->ID , 'thumbnail' ); ?>" rel="lightbox"><div class="home-thumbs"><?php echo wp_get_attachment_image( $image->ID , 'thumbnail' ); ?></div><!--end home-thumbs--></a>
  11. <?php   }
  12.     } ?>
  13.  
  14.     <?php endwhile;
  15.  
  16.     // Reset Query
  17.     wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement