Skip to content

Instantly share code, notes, and snippets.

Created August 8, 2012 23:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Footer Widget and Custom Count Widgets Class for WLFW
'name' => __( 'Footer Sidebar' ),
'id' => 'footer-sidebar',
'description' => __( 'Widgets in this area will be shown on the footer.' ),
'before_widget' => '<div id="%1$s" class="grid_4 widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>'
add_filter('dynamic_sidebar_params', 'wlfw_number_widgets_by_class');
function wlfw_number_widgets_by_class($instance ='', $this='', $args=''){
global $sidebars_widgets;
$sidebars_widgets_flip = array_flip($sidebars_widgets['footer-sidebar']);
$current_count = $sidebars_widgets_flip[$instance[0]['widget_id']];
$instance[0]['before_widget'] = preg_replace('~(.*?class\=\")(.*?)(\".*)~',"$1$2 ".'widget_'.($current_count+1)."$3",$instance[0]['before_widget']);
return $instance;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment