[Resolved] Create an archive for gallery format posts
I am trying to make a page for gallery format posts but have it grouped by year so that you only view the posts with the gallery format for a certain year. So far I have all the posts on one page but there is a lot. I also couldn’t get paging to work so I gave up on that but would prefer to have it as that is a lot of posts on one page.
The code I am currently using (without years or paging) is…
<ul id="gallery-list"> <?php $args = array( 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-gallery' ), 'operator' => 'IN', ) ), 'posts_per_page' => 10000 ); $gallery = new WP_Query( $args ); if($gallery->have_posts()): while($gallery->have_posts()): $gallery->the_post();?> <li class="format-gallery"> <?php $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) ); if ( $images ) : $total_images = count( $images ); $image = array_shift( $images ); ?> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?> <h3><?php the_title(); ?></h3> </a> <?php printf( _n( ' (%1$s photos)', ' (%1$s photos)', $total_images, 'simple' ), number_format_i18n( $total_images ) ); ?> <?php endif; ?> </li> <?php endwhile; endif; ?> </ul>
An example of what I have got can be viewed at themes.candaceduffyjones.com/type/gallery/?theme=Simple. That is just my test site since the website I am working on is a members only website, but the test site will work fine it just has less galleries.
- The topic ‘[Resolved] Create an archive for gallery format posts’ is closed to new replies.