Advertisement
Guest User

image query for wordpress

a guest
Aug 16th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php query_posts( array( 'category__and' => array(1), 'posts_per_page' => 2, '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. $count = 0;
  10. foreach ( $images as $image ) { ?>
  11. <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>
  12. <?php $count++; ?>
  13. <?php if ($count == 6) break; ?>
  14. <?php }
  15. } ?>
  16.  
  17. <?php endwhile;
  18.  
  19. // Reset Query
  20. wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement