简体   繁体   English

WordPress主题TwentyThirteen php-需要不显示侧边栏

[英]WordPress Theme TwentyThirteen php - need to not display sidebar

I'm using WP TwentyThirteen , yes a child theme. 我正在使用WP TwentyThirteen ,是一个儿童主题。 TwentyThirteen comes with a footer area sidebar as the main sidebar and it is called after content and before the <?php get_footer(); ?> TwentyThirteen带有一个页脚区域侧栏作为主要侧栏,它在内容之后且<?php get_footer(); ?>之前被调用<?php get_footer(); ?> <?php get_footer(); ?> . <?php get_footer(); ?> There is also an optional right-hand sidebar, if you put widgets in it then it will appear. 还有一个可选的右侧边栏,如果您在其中添加了小部件,则它将出现。

Here's the question part: I want the sidebar with the widgets to show on pages that are posts but not show on pages that are just pages. 这是问题部分:我希望带有小部件的边栏显示在帖子页面上,而不显示在仅页面上。 I'm making a combination blog/portfolio site for myself: http://marginalia.wendywainwright.com . 我正在为自己创建一个组合博客/组合站点: http : //marginalia.wendywainwright.com

So the first three items on the navbar are "blog," "ideas," and "life." 因此,导航栏上的前三个项目是“博客”,“想法”“生活”。 I will only be putting posts posts on those pages. 我只会在这些页面上发布帖子。

The rest of the navbar Portfolio, About, and Contact will be page pages and will not have posts but will have sub-pages. 导航栏的“投资组合”,“关于”和“联系人”的其余部分将是页面页面,没有帖子,但有子页面。 I want to have that right-hand side bar on the post pages and have it hidden on the page pages. 我想在帖子页面上使用该右侧栏,并将其隐藏在页面页面上。 I think I might have a sort of ghetto CSS way of figuring it out but I'd really appreciate it if someone could help me do it correctly/best practices. 我想我可能会有一种贫民窟的CSS方式来解决它,但是如果有人可以帮助我正确/最佳实践,我将非常感激。

try adding an if statement around your right hand sidebar php code and use one of the WordPress methods 尝试在右侧工具栏php代码周围添加if语句,并使用WordPress方法之一

view both of these methods is_single() or is_page() 查看这两个方法is_single()is_page()

http://codex.wordpress.org/Function_Reference/is_single http://codex.wordpress.org/Function_Reference/is_single

<?php
if( is_single($post) ){
     // is post - sidebar php code goes here
}
?> 

http://codex.wordpress.org/Function_Reference/is_page http://codex.wordpress.org/Function_Reference/is_page

<?php
if( is_page($page) ){
     // is page - sidebar php code goes here
}
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM