Created
March 20, 2012 20:13
-
-
Save billerickson/2140818 to your computer and use it in GitHub Desktop.
Better grid loop for secondary query
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: Books **/ | |
add_action( 'genesis_after_post_content', 'be_list_posts' ); | |
/** | |
* List Posts | |
* | |
*/ | |
function be_list_posts() { | |
$args = array( | |
'post_type' => 'books', | |
'posts_per_page' => -1 | |
); | |
$loop = new WP_Query( $args ); | |
if( $loop->have_posts() ): | |
echo '<div class="book-listing">'; | |
while( $loop->have_posts() ): $loop->the_post(); | |
$classes = 'book one-third'; | |
if( 0 == $loop->current_post || 0 == $loop->current_post % 3 ) | |
$classes .= ' first'; | |
echo '<div id="book-' . $loop->current_post . '" class="' . $classes . '">'; | |
the_post_thumbnail(); | |
the_title(); | |
echo '</div><!-- .book -->'; | |
endwhile; | |
echo '</div><!-- .book-listing -->'; | |
endif; | |
wp_reset_query(); | |
} | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment