doujiaoben28596 2015-09-17 02:45
浏览 15
已采纳

已注册的WordPress边栏未显示

I have a sidebar in WordPress I've registered like so:

register_sidebar(array(
    'id' => '404',
    'name' => __('404', 'jointstheme'),
    'description' => __('The 404 sidebar.', 'jointstheme'),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="widgettitle">',
    'after_title' => '</h4>',
));

I duplicated my existing 'sidebar.php' file and created a file called: sidebar-404.php.

I also added the call to my sidebar in the 404 page template like so:

<?php get_sidebar('404'); ?>

Yet for some reason, my theme keeps defaulting to the default sidebar.

Anyone have any ideas what might be going on?

Thanks!

  • 写回答

1条回答 默认 最新

  • douxiaomang5640 2015-09-17 04:50
    关注

    When you register a sidebar in your functions.php file and want to use the widget manager in from the admin panel, you need to use dynamic siderbars not get_sidebar. get_sidebar will only display the widgets that are coded into the file.

    Instead of <?php get_sidebar('404'); ?> you should have something like <?php dynamic_sidebar( '404' ); ?>

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线