Advertisement
adnan360

Wordpress: List all images in a "Image Archive" page

Mar 29th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: My Image Archives
  4. */
  5. get_header(); ?>
  6.  
  7. <div id="primary" class="site-content">
  8. <div id="content" role="main">
  9.  
  10. <?php
  11. $query_images_args = array(
  12.         'post_type' => 'attachment',
  13.         'post_status' => 'inherit',
  14.         'posts_per_page' => -1,
  15.     );
  16.  
  17. $query_images = new WP_Query( $query_images_args );
  18. //$images = array();
  19. $ids='';
  20. foreach ( $query_images->posts as $image) {
  21.     $ids.=','.$image->ID;
  22. }
  23. echo do_shortcode('[gallery ids="'.$ids.'"]');
  24. ?>
  25.  
  26. </div><!-- #content -->
  27. </div><!-- #primary -->
  28.  
  29. <?php get_sidebar(); ?>
  30. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement