两个自定义侧边栏在我的主题中变得不活跃,我不知道为什么,也不知道如何修复它。我用的是一个基于十七岁的儿童主题。他们以前工作得很好。
下面是注册侧边栏并将其添加到首页模板的代码。输出标记确认正在使用正确的模板文件。

theme-functions.php
function twentyseventeenchild_widgets_init() {
register_sidebar(
array(
'name' => __( 'Home Sidebar', 'twentyseventeenchild' ),
'id' => 'sidebar-4',
'description' => __( 'Add widgets here to appear in your sidebar on the homne page.', 'twentyseventeenchild' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
)
);
register_sidebar(
array(
'name' => __( 'Home pano', 'twentyseventeenchild' ),
'id' => 'home-pano',
'description' => __( 'Add widgets here to appear above the homepage content.', 'twentyseventeenchild' ),
)
);
}front-page.php
<aside id="home-pano" class="widget-area" role="complementary" aria-label="<?php esc_attr_e( 'Home pano', 'twentyseventeen' ); ?>">
<?php dynamic_sidebar( 'home-pano' ); ?>
</aside>
<aside id="secondary" class="widget-area" role="complementary" aria-label="<?php esc_attr_e( 'Home Sidebar', 'twentyseventeen' ); ?>">
<?php dynamic_sidebar( 'sidebar-4' ); ?>
</aside>主页上的输出


发布于 2021-03-24 14:56:20
我遗漏了文件底部的以下一行:
add_action( 'widgets_init', 'twentyseventeenchild_widgets_init' );https://stackoverflow.com/questions/66636058
复制相似问题