The general concept on dynamic sidebars
Basically WP loops through the global $wp_registered_widgets
and builds the widget depending on it’s arguments. You can intercept them easily:
Use a filter
You can use the dynamic_sidebar_params
to add a class to target specific widgets:
// SHOW the params for better insights
function wpse44903_dump_sidebar_params( $params )
{
echo '<pre>';
print_r( $params );
echo '</pre>';
return $params;
}
add_filter( 'dynamic_sidebar_params', 'wpse44903_dump_sidebar_params' );
Then you can simply alter whatever you need (depending on your situation):
// ALTER the params to your needs
function wpse44903_alter_sidebar_params( $params )
{
// remove trailing and leading white space and use only lower case characters to be on the save side of things
if ( 'YOUR WIDGET NAME' === trim( strtolower( $params[0]['widget_name'] ) ) )
{
// do whatever you need to do.
// @example:
foreach ( $wp_registered_widgets as $widget )
if ( in_array( $params[0]['widget_name'], $widget ) )
print_r( $widget );
}
return $params;
}
add_filter( 'dynamic_sidebar_params', 'wpse44903_alter_sidebar_params' );
Note: This is not tested and maybe needs some bug fixing. Be sure to turn WP_DEBUG
to TRUE
in your wp-config.php file.