You need to enable JavaScript to run this app. WordPress twentyseventeen子主题自定义侧边栏突然失效排查
优惠活动
大模型
产品
解决方案
定价
更多

WordPress twentyseventeen子主题自定义侧边栏突然失效排查

基于Twenty Seventeen的子主题自定义侧边栏失效问题

我基于Twenty Seventeen搭建了子主题,此前配置的两个自定义侧边栏可正常运行,现在变为未激活状态,暂未定位到问题成因,也没有可行的修复思路。
我已确认当前首页实际加载的就是目标模板文件,侧边栏的注册、调用相关代码如下。

关联代码片段

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>

实际运行表现

页面加载时可正常输出上述代码定义的侧边栏容器DOM结构,但容器内挂载的小组件没有正常渲染输出,相关场景配图包含后台侧边栏状态、前端页面显示效果、DOM结构展示三类内容。

内容的提问来源于stack exchange,提问作者AJP

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.29 21:15:04