Skip to content

Instantly share code, notes, and snippets.

@emirpprime emirpprime/mod_rows.php
Last active Sep 7, 2016

Embed
What would you like to do?
Modulus example to create rows in a grid
<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
You can’t perform that action at this time.