Skip to content

Instantly share code, notes, and snippets.

@retlehs
Created May 15, 2012 17:44
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save retlehs/2703644 to your computer and use it in GitHub Desktop.
Save retlehs/2703644 to your computer and use it in GitHub Desktop.
Add a class to widgets in a specific sidebar
<?php
/**
* Add 'class="span4"' to all widgets in the Content Bottom sidebar
*/
function bb_content_bottom_widget_class($params) {
if ($params[0]['id'] == 'roots-content-bottom') {
$class = 'class="span4 ';
$params[0]['before_widget'] = preg_replace('/class=\"/', "$class", $params[0]['before_widget'], 1);
}
return $params;
}
add_filter('dynamic_sidebar_params', 'bb_content_bottom_widget_class');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment