在函数中添加以下代码。主题目录的php文件。用小部件的名称替换小部件名称“主小部件区域”
/*=============WIDGETs CSS CLASS CONTROLLER==============*/
$GLOBALS[\'my_widget_num\']=1;
function edei_widget_class_adder($params){
if( $params[0][\'name\']==\'Home Widget Area\' ){
$GLOBALS[\'my_widget_num\']++;
if( ($GLOBALS[\'my_widget_num\']%4)==0 ){
$params[0][\'before_widget\'] = str_replace(\'class="\', \'class="marginAdjust \', $params[0][\'before_widget\']);
}
}
//print_r($params);
return $params;
}
add_filter(\'dynamic_sidebar_params\',\'edei_widget_class_adder\');
function edei_widget_counter_reset($sidebars_widgets) {
$GLOBALS[\'my_widget_num\'] = 1;
return $sidebars_widgets;
}
add_filter(\'sidebars_widgets\',\'edei_widget_counter_reset\');