我过去在自定义侧边栏方面也遇到过类似的问题。这是由于使用不当造成的<ul>
和<li>
标签。我正在侧边栏中添加它们。php文件,而不是函数内部。现在我使用这段代码,有了6个活动小部件,我就没有错误了。查看代码,如果您有任何问题,请告诉我:
functions.php
<?php
// REGISTER THE SIDBARS
if (!function_exists( \'ideatree_widgets_init\' )) {
function ideatree_widgets_init() {
register_sidebar(array(
\'name\' => __( \'Primary Widget Area\', \'ideatree\' ),
\'id\' => \'primary-widget-area\',
\'description\' => \'The primary widget area\', \'ideatree\',
\'before_widget\' => \'<ul><li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li></ul>\',
\'before_title\' => \'<h3 class="widgettitle">\',
\'after_title\' => \'</h3>\',)
);
register_sidebar(array(
\'name\' => \'Secondary Widget Area\', \'ideatree\',
\'id\' => \'secondary-widget-area\',
\'description\' => \'The secondary widget area\', \'ideatree\',
\'before_widget\' => \'<ul><li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li></ul>\',
\'before_title\' => \'<h3 class="widgettitle">\',
\'after_title\' => \'</h3>\',)
);
}
add_action(\'widgets_init\', \'ideatree_widgets_init\');
}
?>
sidebar.php
<div class="wrapper sidebar">
<div id="upper-sidebar">
<?php if ( ! dynamic_sidebar( \'primary-widget-area\' ) ) : ?>
<?php endif; ?>
</div><!-- END UPPER-SIDEBAR -->
<div id="lower-sidebar">
<?php if ( ! dynamic_sidebar( \'secondary-widget-area\' ) ) : ?>
<?php endif; ?>
</div><!-- END LOWER-SIDEBAR -->
</div><!-- END SIDEBAR -->