在 wordpress 子主题中添加两个侧边栏 [英] Adding two sidebars in wordpress child theme
问题描述
在 Wordpress
中,我想制作两个侧边栏.一个将在内容的左侧,另一个将在 twentyelven 主题的右侧(默认侧边栏).为此,我对我的 211 个子主题进行了一些自定义.在functions.php中我做了这个改变
register_sidebar( 数组('名称' =>__( '左侧边栏', 'buygames' ),'id' =>'侧边栏-左','before_widget' =>'<aside id="%1$s" class="widget %2$s">','after_widget' =>"</一边>",'before_title' =>'<h3 class="widget-title">','after_title' =>'</h3>',) );
然后在 sidebar-page.php 我添加了这段代码
<?php dynamic_sidebar('sidebar-left');?></div><!--#left-sidebar-->就在代码 get_header();
之后和 <div id="primary">....</div>
之前.这工作正常,但我认为这是错误的方法.通过这样做,它将被硬编码.那么有人可以建议我在不进行任何硬编码的情况下做到这一点的好方法是什么?任何帮助和建议都将受到高度赞赏.
解决方案 您可以将两个侧边栏添加到子主题的 sidebar.php 中,并按 css 排列.
//你的侧边栏<div id="左侧边栏"><?php dynamic_sidebar('sidebar-left');?></div><!--#left-sidebar-->//原始侧边栏<div id="侧边栏"><?php dynamic_sidebar('侧边栏');?></div><!--#sidebar-->
一定要添加两个侧边栏,因为你的子主题的 sidebar.php 覆盖了原来的.
In Wordpress
I want to make two sidebars. One will be in left hand side of the content and the other one will be in the right hand side (default sidebar) in twentyelven theme. For that I made little bit customization to my twentyeleven child theme.
In functions.php I made this changes
register_sidebar( array(
'name' => __( 'Left Hand Sidebar', 'buygames' ),
'id' => 'sidebar-left',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
Then in sidebar-page.php I added this code
<div id="left-sidebar">
<?php dynamic_sidebar( 'sidebar-left' ); ?>
</div><!--#left-sidebar-->
just after the code get_header();
and before the <div id="primary">....</div>
.
This is working fine but I think this is the wrong method. By doing this it will be hard-coded. So can some one suggest me what will be the good way to do this without making any hard coding? Any help and suggestions will be highly appreciable.
解决方案 You can add both sidebars to the sidebar.php of your childtheme and arrange them per css.
// your sidebar
<div id="left-sidebar">
<?php dynamic_sidebar( 'sidebar-left' ); ?>
</div><!--#left-sidebar-->
// original sidebar
<div id="sidebar">
<?php dynamic_sidebar( 'sidebar' ); ?>
</div><!--#sidebar-->
Be sure to add both sidebars because the sidebar.php of your child theme overwrites the original one.
这篇关于在 wordpress 子主题中添加两个侧边栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
相关文章
- 从任何主题中删除 Woocommerce 侧边栏;
- 下划线 Wordpress 主题 - 添加第二个侧边栏;
- 如何在 Wordpress 子主题中编译 SASS?;
- 如何在Wordpress主题中添加Ajax;
- 如何覆盖 WordPress 子主题中的小部件?;
- 在主题激活时将小部件添加到自定义 WordPress 侧边栏?;
- 如何制作wordpress侧边栏;
- 在 wordpress 主题中启用短代码;
- 在 WordPress 主题中除以零错误;
- 图像未显示在 wordpress 主题中;
- 如何在WordPress的子主题中覆盖小部件?;
- 在两个主题中显示具有MINUMUM MARKS的卷筒?;
- 在 Wordpress 中显示活动侧边栏;
- 子主题的Wordpress子主题;
- WordPress主题中的分页帖子;
- 如何合并两个在wordpress中单独管理的菜单以在前端主题中显示为一个?;
- 交替颜色行 - 不适用于两个侧边栏;
- 关于 WordPress 子主题;
- 如何在WordPress主题中包含jQuery?;
- 从当前前端获取 WordPress 侧边栏;
- WordPress:覆盖子主题中的父主题类功能;
- WordPress 子主题覆盖父主题包括;
- 如何在wordpress管理侧边栏上添加自定义链接;
- 光滑的滑块拇指未显示在 wordpress 主题中;
- 如何添加子菜单到WordPress管理栏;
其他开发最新文章
- 拒绝显示一个框架,因为它将'X-Frame-Options'设置为'sameorigin';
- 什么是&QUOT; AW&QUOT;在部分标志属性是什么意思?;
- 在运行npm install命令时获取'npm WARN弃用'警告;
- cmake无法找到openssl;
- 从Spark的scala中的* .tar.gz压缩文件中读取HDF5文件;
- Twitter :: Error :: Forbidden - 无法验证您的凭据;
- 我什么时候需要一个fb:app_id或者fb:admins?;
- 将.db文件导入R;
- npm通知创建一个lockfile作为package-lock.json。你应该提交这个文件;
- 拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“script-src'self'”;