Last active
December 10, 2015 00:48
-
-
Save wwdboer/4353601 to your computer and use it in GitHub Desktop.
WordPress: Modulo example to create rows
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 | |
global $post; | |
$args = array( | |
'post_type' => 'post', | |
'posts_per_page' => -1 | |
); | |
$new_query = new WP_Query($args); | |
$post_count = 0; | |
$total_posts = $new_query->post_count; | |
?> | |
<?php while( $new_query->have_posts() ) : $new_query->the_post(); ?> | |
<?php $post_count++ ?> | |
<?php if ($post_count % 3 == 1) : ?> | |
<div class="row-fluid"> | |
<?php endif; ?> | |
<div class="span4"> | |
</div> | |
<?php if ( $post_count % 3 == 0 || $post_count == $total_posts ) : ?> | |
</div> | |
<?php endif; ?> | |
<?php endwhile; ?> | |
<?php wp_reset_postdata(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment