Created
January 15, 2014 15:17
-
-
Save tjhole/8438083 to your computer and use it in GitHub Desktop.
WORDPRESS: Query Posts - Break into Rows
This file contains hidden or 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 | |
$args = array( | |
'post_type' => 'posts', | |
'posts_per_page' => -1, | |
); | |
$total = 0; | |
query_posts($args); | |
while ( have_posts() ) : the_post(); | |
$total++; endwhile; wp_reset_query(); | |
query_posts($args); | |
$countimg = 0; while ( have_posts() ) : the_post(); $countimg++; | |
if($countimg == 1) { echo "<div class='row'>";} ?> | |
<div class="columns large-3"> | |
<?php echo $countimg; echo ": "; the_title();?> | |
</div> | |
<?php | |
if ( $countimg == ($total) ) { | |
echo "</div>"; | |
} else { | |
if ( $countimg % 4 == 0 ) { echo "</div><div class='row'>";} | |
} | |
endwhile; wp_reset_query(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment