Skip to content

Instantly share code, notes, and snippets.

@scarstens
Created August 8, 2012 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scarstens/3299644 to your computer and use it in GitHub Desktop.
Save scarstens/3299644 to your computer and use it in GitHub Desktop.
Footer Widget and Custom Count Widgets Class for WLFW
<?php
register_sidebar(array(
'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']);
//var_export($instance);
return $instance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment