Last active
September 7, 2016 19:34
-
-
Save phlbnks/d6df6c9c6d0edbaa45230197f15929fa to your computer and use it in GitHub Desktop.
Modulus example to create rows in a grid
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
<div class="row"> | |
<?php | |
// $posts is some content to loop over and output. | |
$posts_count = 0; | |
foreach ( $posts as $post ) : | |
echo $post; | |
if ( $posts_count % 3 == 2 ) : // Fires every 3rd item since we are counting from 0. ?> | |
</div><div class="row> | |
<?php endif; | |
$posts_count++; | |
endforeach; | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment