如果以这种方式注册侧栏,则所有动态小部件都会自动获得一个唯一的类,例如-class="widget-container widget_archive"
register_sidebar( array(
\'name\' => __( \'Primary Widget Area\', \'twentyten\' ),
\'id\' => \'primary-widget-area\',
\'description\' => __( \'The primary widget area\', \'twentyten\' ),
\'before_widget\' => \'<li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li>\',
\'before_title\' => \'<h3 class="widget-title">\',
\'after_title\' => \'</h3>\',
) );
注意-
\'before_widget\' => \'<div id="%1$s" class="widget %2$s">\',
" %1$s "
- 将打印唯一的小部件id。" %2$s "
- 将打印每个小部件的唯一类
然后,我们可以根据需要对该唯一类应用自定义样式。
参考-Codex - Register Sidebar