我的WordPress主题有一期。
您的主题还有另外两个小部件区域,但此特定页面不显示它们。您可以导航到站点上的其他页面,同时使用自定义程序查看和编辑这些页面上显示的小部件。
我的widgets页面上总共有8个widget,我添加了Wordpress search widgets
在universal search widgets
但它没有显示出来。
然后我检查了一下
Appearance-> Customizeon
但它只显示了6个。
你能帮我解决这个问题吗?我试着在谷歌上搜索,但没有找到解决方案。
I am using below code
/*universal search */
function universalSearch() {
register_sidebar( array(
\'name\' => \'Universal Search\',
\'id\' => \'universalSearchField\',
\'before_widget\' => \'<div class="chw-widget">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h2 class="chw-title">\',
\'after_title\' => \'</h2>\',
) );
}
add_action( \'widgets_init\', \'universalSearch\' );
function universalSearch1() {
register_sidebar( array(
\'name\' => \'Universal Search1\',
\'id\' => \'universalSearch1\',
\'before_widget\' => \'<div class="chw-newsletter">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h2 class="chw-newsletter_title">\',
\'after_title\' => \'</h2>\',
) );
}
add_action( \'widgets_init\', \'universalSearch1\' );
Displaying on page
<?php if ( is_active_sidebar(\'universalSearchField\')) :
dynamic_sidebar(\'universalSearchField\');
endif; ?>
最合适的回答,由SO网友:Chetan Vaghela 整理而成
更改寄存器侧栏的Id。我已经测试过了,更换id后效果很好。如果这能解决您的问题,请告诉我。
function universalSearch() {
register_sidebar( array(
\'name\' => \'Universal Search\',
\'id\' => \'universal-search-field\',
\'before_widget\' => \'<div class="chw-widget">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h2 class="chw-title">\',
\'after_title\' => \'</h2>\',
) );
register_sidebar( array(
\'name\' => \'Universal Search1\',
\'id\' => \'universal-search-field-1\',
\'before_widget\' => \'<div class="chw-newsletter">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h2 class="chw-newsletter_title">\',
\'after_title\' => \'</h2>\',
) );
}
add_action( \'widgets_init\', \'universalSearch\' );
Displaying on page
if ( is_active_sidebar(\'universal-search-field\')) :
dynamic_sidebar(\'universal-search-field\');
endif;
if ( is_active_sidebar(\'universal-search-field-1\')) :
dynamic_sidebar(\'universal-search-field-1\');
endif;