Skip to content

Instantly share code, notes, and snippets.

@derick-montague
Created August 11, 2012 02:32
Show Gist options
  • Save derick-montague/3320099 to your computer and use it in GitHub Desktop.
Save derick-montague/3320099 to your computer and use it in GitHub Desktop.
WordPress scripts for 3 column layout that checks to see if the element is the middle in a three column layout or a new row. Use it to clear floats and add styles such as left and right margins for the middle column.
// Custom function to check if column is middle column
// of a three column layout based on the index
function is_middle_column($index)
{
$isMiddleColumn = false;
$postIndex = $index;
if (($postIndex - 1) % 3 == 0)
{
$isMiddleColumn = true;
}
return $isMiddleColumn;
}
function is_new_row($index)
{
$isNewColumn = false;
$postIndex = $index;
if (($postIndex > 0) && ($postIndex % 3 == 0))
{
$isNewColumn = true;
}
return $isNewColumn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment