Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 19, 2013 14:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/4572998 to your computer and use it in GitHub Desktop.
Save billerickson/4572998 to your computer and use it in GitHub Desktop.
<?php
/* Template Name: Grid Archive */
/**
* Grid Archive Loop
*
*/
function be_grid_archive_loop() {
$categories = get_categories();
foreach( $categories as $category ) {
$args = array(
'posts_per_page' => -1,
'post_type' => 'post',
'cat' => $category->term_id,
);
$loop = new WP_Query( $args );
if( $loop->have_posts() ) {
echo '<h3>' . $category->name . '</h3>';
echo '<div class="grid-listing">';
while( $loop->have_posts() ) {
$loop->the_post();
global $post;
$class = 0 == $loop->current_post || 0 == $loop->current_post % 2 ? 'one-half first' : 'one-half';
echo '<div class="' . $class . '">';
echo '<p class="title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></p>';
echo '<p class="image"><a href="' . get_permalink() . '">' . get_the_post_thumbnail( $post->ID, 'grid-thumbnail' ) . '</a></p>';
echo '</div>';
} // endwhile
echo '</div>';
} // endif
} // endforeach
wp_reset_postdata();
}
add_action( 'genesis_loop', 'be_grid_archive_loop' );
remove_action( 'genesis_loop', 'genesis_do_loop' );
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment