admin管理员组文章数量:1333181
I'm developing a theme via an online course and I can't get the sidebar to display.
I've used the hook widget_init and the function is being called because I can echo text out. Index.php is correctly able to read from sidebar.php because I can echo lines of code from there.
The problem seems to be that when I drag and drop widgets on the dashboard it's not saving them so my sidebar is always displaying as empty/false. It does show that it's saved but if I leave that area of the dashboard and go back to it everything has reset and I'm left with an empty sidebar.
Running the code below I get 'side bar not active' (from my echo) Any help would be appreciated.
//functions.php
include(get_theme_file_path( '/includes/widgets.php' ));
//widgets.php
<?php
function JU_widgets(){
echo 'Test JU_WIDGET Function';
register_sidebar( [
'name' => __('My First Theme Sidebar', 'udemy'),
'id' => 'MM_sidebar',
'description' => __('Udemy widget example', 'udemy')
] );
} ?>
//sidebar.php
<?php if( is_active_sidebar( 'MM_sidebar' ) ){
echo 'sidebar active';
dynamic_sidebar( 'MM_sidebar' );
}else{
echo 'side bar not active';
} ?>
本文标签: Sidebar not displaying (theme development)
版权声明:本文标题:Sidebar not displaying (theme development) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742287300a2447158.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论