Created
January 19, 2013 14:37
-
-
Save billerickson/4572998 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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