下划线 WordPress 主题 - 添加第二个侧边栏


Underscores Wordpress Theme - Adding second sidebar

使用下划线主题盯着Wordpress网站(_s)

我有一个侧边栏

在工作,但想让第二个侧边栏在同一页面上。(包含不同的小部件)

我已经将新的侧边栏添加到功能中.php它出现在 Wordpress 登录屏幕中,我可以将小部件放入其中。但是,我无法让它显示在实际网页上。(第一个侧边栏工作正常)

任何人都知道如何做到这一点或知道教程...

谢谢

您需要编辑主题文件夹中的"侧边栏.php"文件。它通常应该是:

<div id="secondary" class="widget-area" role="complementary">
    <?php do_action( 'before_sidebar' ); ?>
    <?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?>
    <?php endif; // end sidebar-1 widget area ?>
</div><!-- #secondary -->

您将需要添加另一个 if 语句来查找另一个侧边栏。请务必通过您在 functions.php 文件中使用的任何内容来引用它。

如果您希望它显示在当前侧边栏下方,请务必在关闭"div"之前添加它,以便它仍然在同一列中。我使用了"侧边栏下部":

<div id="secondary" class="widget-area" role="complementary">
    <?php do_action( 'before_sidebar' ); ?>
    <?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?>
    <?php endif; // end sidebar-1 widget area ?>
    <?php if ( ! dynamic_sidebar( 'sidebar-lower' ) ) : ?>
    <?php endif; // end sidebar-lower widget area ?>
</div><!-- #secondary -->