我决定开始一个新问题。来自先前one的信息,因为我认为我错过了重点。
我正在尝试在我正在设计的博客的主要家中有两个侧边栏(同时)。现在我已经实现了它,但是以凌乱的方式......
我(想)我注册了两个侧边栏,为两者制作了html代码,并在Css中设置了两种风格。
但我对PHP的了解很少,以至于我无法知道如何在maing页面中调用侧边栏。我知道应该使用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管理面板中创建的...)
任何帮助都会受到广泛赞赏,提前谢谢!
答案 0 :(得分:1)
在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