在主页面中调用第二个侧边栏的正确方法


Proper way to call a second sidebar in main page wordpress?

我决定开始一个新的问题。参考上一篇文章的信息,因为我想我没有抓住重点。

我试图有2侧边栏(在同一时间)在我正在设计的博客的主主页。现在我已经实现了,但以一种混乱的方式…

我(认为)我注册了两个侧边栏,为两者制作了html代码,并在Css中设置了样式。但是我在php的知识是如此之少,我不能设法知道侧边栏是如何被称为制作页面。我知道应该使用get_sidebar,但它只在代码中出现一次,并作为一个函数本身。

<?php if ((!in_the_loop() && Bunyad::posts()->meta('layout_style') == 'full') OR Bunyad::core()->get_sidebar() == 'none'): // largest images - no sidebar? ?>

(我认为这个Bunyad插件部分负责…有人之前有过问题吗?)

所以我只是粘贴了第二个侧边栏的html代码,我想它是。

   <div class="row">
  <div class="col-6 main-content">(...)</div>
<?php Bunyad::core()->theme_sidebar(); ?>  <!--I think this calls the first sidebar-->
<aside class="col-2 sidebar2"> <!--this is a copy of the code for the first sidebar that can be found in a separate file called sidebar.php -->
    <ul>
    <?php if (!dynamic_sidebar('cs-sidebar_publicidad')) : ?>
        <?php _e("<li>Nothing yet.</li>", 'bunyad'); ?>
    <?php endif; ?>
    </ul>
</aside>
</div> <!-- .row -->

(cs-sidebar_publicidad是第二个侧边栏的ID,我在WP管理面板中创建的…)

任何帮助是广泛赞赏,提前感谢!

为wp页面添加侧栏或块栏

  • 在主题的functions.php中注册新的侧边栏:http://codex.wordpress.org/Function_Reference/register_sidebar您可以使用第一个侧栏中的现有寄存器代码作为指导;

  • 创建第二个侧边栏模板;可能复制sidebar.php,将其重命名为(例如)sidebar-two.php,调整'dynamic_sidebar('sidebar-1')'(或类似)部分,编辑相应的CSS类和id;http://codex.wordpress.org/Widgetizing_Themes

  • 编辑所有相应的模板,并添加到它需要符合你的html结构的位置;http://codex.wordpress.org/Function_Reference/get_sidebar