一个已经使用了3到4年的自定义页面模板呈现了自定义侧栏,但它突然停止了呈现。我一生都搞不清楚问题出在哪里。
/* functions.php */
/**
* Register Areas sidebars and widgetized areas.
*
*/
function my_widgets_init() {
register_sidebar( array(
\'name\' => \'My Sidebar\',
\'id\' => \'my_sidebar\',
\'before_widget\' => \'<div>\',
\'after_widget\' => \'</div><div> </div>\',
\'before_title\' => \'<h2 class="rounded">\',
\'after_title\' => \'</h2>\',
) );
}
add_action( \'widgets_init\', \'my_widgets_init\' );
/* wordpress page template file*/
<?php if ( is_active_sidebar( \'my_sidebar\' ) ) : ?>
<div>
<?php dynamic_sidebar( \'my_sidebar\' ); ?>
</div>
<?php endif; ?>
在Wordpress仪表板中,按预期为该区域分配了3或4个小部件。但是调用dynamic\\u sidebar()会呈现一个空字符串。有什么想法吗?
* UPDATE *
这是第一个响应中提供的调试代码的输出。Sidebar ID: new_sidebar ( Active)
Sidebar Found
4 Widgets Found
All Sidebars Widgets:
Array
(
[wp_inactive_widgets] => Array
(
[0] => calendar-4
[1] => rss-3
[2] => em_calendar-4
[3] => recent-posts-2
)
[hca_alert_area] => Array
(
)
[SNIP - other sidebars]
[new_sidebar] => Array
(
[0] => search-2
[1] => nav_menu-2
[2] => em_widget-2
[3] => recent-posts-3
)
[footer-sidebar] => Array
(
[0] => nav_menu-3
)
[array_version] => 3
)
我花了大量时间试图解决这个问题。该站点使用不再受支持的Cherry框架模板版本。如果我能解决这个问题,我不愿意仅仅因为这个问题而更新整个主题。