Skip to content

Instantly share code, notes, and snippets.

@apisandipas
Created January 13, 2015 15:39
Show Gist options
  • Select an option

  • Save apisandipas/a81aaca851881f80114c to your computer and use it in GitHub Desktop.

Select an option

Save apisandipas/a81aaca851881f80114c to your computer and use it in GitHub Desktop.
Dynamic html rows for the Loop
/**
* When Looping over a collection of posts, this will configure and out put the row seperator in the correct place.
*
* Must be used within the Loop
*
* @param integer $numCols the number of columns in each row iteration
* @param string $rowSeperator the html output to seperate the rows, defaults to: </div><div class='row'>
* @return string
*/
function bp_dynamic_rows( $numCols = 2, $rowSeperator = "</div><div class='row'>" ){
global $wp_query;
if ( ( $wp_query->current_post + 1 ) % $numCols == 0 ):
echo $rowSeperator;
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment