Created
January 19, 2013 14:27
-
-
Save billerickson/4572940 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 */ | |
/** | |
* Category Loop | |
* | |
*/ | |
function be_category_loop() { | |
global $post, $wp_query; | |
$args = array( | |
'posts_per_page' => 20, | |
'post_type' => 'post', | |
'paged' => get_query_var( 'paged' ), | |
'cat' => (int) get_post_meta( $post->ID, 'query_args', true ), | |
); | |
$wp_query = new WP_Query( $args ); | |
if( $wp_query->have_posts() ): | |
while( $wp_query->have_posts() ): $wp_query->the_post(); global $post; | |
$classes = 0 == $wp_query->current_post || 0 == $wp_query->current_post % 2 ? 'post one-half first' : 'post one-half'; | |
echo '<div class="' . $classes . '">'; | |
echo '<h2 class="entry-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>'; | |
echo '<div class="entry-content">'; | |
echo '<a href="'.get_permalink().'">' . get_the_post_thumbnail( null, 'grid-thumbnail' ) . '</a>'; | |
echo '</div>'; | |
echo '</div>'; | |
endwhile; | |
genesis_posts_nav(); | |
endif; | |
wp_reset_query(); | |
} | |
add_action( 'genesis_loop', 'be_category_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
Assumptions:
Note: This really shouldn't be done through a custom page template. Use the standard category archive (template: category.php) and you won't need to do a custom query.