Skip to content

Instantly share code, notes, and snippets.

@joeyblake
Created March 2, 2016 04:08
Show Gist options
  • Save joeyblake/8fab86e4c71654c19cdb to your computer and use it in GitHub Desktop.
Save joeyblake/8fab86e4c71654c19cdb to your computer and use it in GitHub Desktop.
//row markup
$row = '<div class="row-fluid">%s</div>'
//$posts = whatever you are trying to put in a grid.
$span_divs = array();
foreach ( $posts as $post ) {
//make a span box
$span_divs[] = sprintf( "<div class="span4">%s</div>" , $post);
}
//chunk the array of grid items into a number if items
foreach ( array_chunk($span_divs, 3) as $spans ) {
//pull the chunked array markup into the row markup and write it out
echo sprintf($row, implode('', $spans));
}
@Wh04m1x
Copy link

Wh04m1x commented Jan 6, 2020

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment