我正在开发一个新主题,并在这个主题中使用了几个侧边栏。所有这些都很好,但小部件没有显示在主题定制器部分。在“外观->小部件”部分,所有小部件都可以正常工作,但在“外观->自定义”部分,则不能正常工作。我正在使用wordpress 3.9.1。
这就是我在函数中声明它们的方式。php
if(function_exists(\'register_sidebar\'))
{
register_sidebar ( array (
\'name\' => \'Widget Area 1\',
\'id\' => \'widget-1\',
\'description\' => \'Widget Area 2.\',
\'before_widget\' => \'<div id="%2$s" class="widget %2$s">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h3>\',
\'after_title\' => \'</h3>\' ,
) );
register_sidebar ( array (
\'name\' => \'Widget Area 2\',
\'id\' => \'widget-2\',
\'description\' => \'Widget Area 2.\',
\'before_widget\' => \'<div id="%2$s" class="widget %2$s">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h3>\',
\'after_title\' => \'</h3>\' ,
) );
register_sidebar ( array (
\'name\' => \'Widget Area 3\',
\'id\' => \'widget-3\',
\'description\' => \'Widget Area 3.\',
\'before_widget\' => \'<div id="%2$s" class="widget %2$s">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h3>\',
\'after_title\' => \'</h3>\' ,
) );
register_sidebar ( array (
\'name\' => \'Widget Area 4\',
\'id\' => \'widget-4\',
\'description\' => \'Widget Area 4.\',
\'before_widget\' => \'<div id="%2$s" class="widget %2$s">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h3>\',
\'after_title\' => \'</h3>\' ,
) );
}
我就是这样称呼他们的。
<?php
if (! function_exists ( \'dynamic_sidebar\' ) || ! dynamic_sidebar ( \'Widget Area 1\' )) :
endif;?>
当我有一个小部件区域时,它显示良好,但一旦我添加多个小部件,它就会从customizer中消失。