Skip to content

Instantly share code, notes, and snippets.

@topleague
Created August 31, 2017 18:04
Show Gist options
  • Save topleague/2cec0245db8678b985ad2a67c68ecd1a to your computer and use it in GitHub Desktop.
Save topleague/2cec0245db8678b985ad2a67c68ecd1a to your computer and use it in GitHub Desktop.
Set up Widget Counts in Genesis Sample
//* Setup widget counts
function genesis_count_widgets( $id ) {
global $sidebars_widgets;
if ( isset( $sidebars_widgets[ $id ] ) ) {
return count( $sidebars_widgets[ $id ] );
}
}
function genesis_widget_area_class( $id ) {
$count = genesis_count_widgets( $id );
$class = '';
if ( $count == 1 ) {
$class .= ' widget-full';
} elseif ( $count % 3 == 1 ) {
$class .= ' widget-thirds';
} elseif ( $count % 4 == 1 ) {
$class .= ' widget-fourths';
} elseif ( $count % 2 == 0 ) {
$class .= ' widget-halves uneven';
} else {
$class .= ' widget-halves';
}
return $class;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment