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

标签 php html wordpress themes sidebar

使用下划线主题 (_s) 启动 Wordpress 网站

我有一个侧边栏可以正常工作,但想在同一页面上制作第二个侧边栏。 (包含不同的小部件)

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

任何人都知道如何执行此操作或了解教程...

谢谢

最佳答案

您需要编辑主题文件夹中的“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 -->

关于php - 下划线 Wordpress 主题 - 添加第二个侧边栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19334974/

相关文章:

php - 如何在codeigniter中配置两个数据库?

php - 如何在 cakePHP 2.x 中生成 CSV 文件?

html - 如何在不访问页面中所有 img 的情况下将 img 移动到 div 中?

PHP根据一个字段的值将数组分成几组

php - 不明白为什么我的联系表不发送电子邮件

javascript - jQuery .after() 函数有什么替代方法吗

php - 根据 URL 查询参数切换 Wordpress 帖子模板

php - 使用 Woocommerce 更新 Wordpress 上的用户信息?

html - 缩放带有内容的背景图像

html - 在 HTML ID 中使用数据库主键