Created
August 11, 2012 02:32
-
-
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.
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
// 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; | |
} |
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
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