强调Wordpress主题 - 添加第二个侧边栏

时间:2013-10-12 13:54:29

标签: php html wordpress themes sidebar

使用Underscores主题(_s)

标记了一个Wordpress网站

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

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

任何人都知道如何做或知道教程...

由于

1 个答案:

答案 0 :(得分:0)

您需要编辑主题文件夹中的“sidebar.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'之前添加它,以便它仍然在同一列中。我使用'sidebar-lower':

<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 -->
相关问题