首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wordpress -不确定为什么侧边栏在我的子主题中变得不活跃

Wordpress -不确定为什么侧边栏在我的子主题中变得不活跃
EN

Stack Overflow用户
提问于 2021-03-15 10:17:19
回答 1查看 28关注 0票数 0

两个自定义侧边栏在我的主题中变得不活跃,我不知道为什么,也不知道如何修复它。我用的是一个基于十七岁的儿童主题。他们以前工作得很好。

下面是注册侧边栏并将其添加到首页模板的代码。输出标记确认正在使用正确的模板文件。

theme-functions.php

代码语言:javascript
复制
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

代码语言:javascript
复制
<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>

主页上的输出

EN

回答 1

Stack Overflow用户

发布于 2021-03-24 14:56:20

我遗漏了文件底部的以下一行:

代码语言:javascript
复制
add_action( 'widgets_init', 'twentyseventeenchild_widgets_init' );
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66636058

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档