简体   繁体   English

如何从页面中排除边栏?

[英]How to exclude sidebar from pages?

How to exclude sidebar from pages? 如何从页面中排除边栏? I put some page id's in exclude page in appearance -> widget -> pages -> left sidebar. 我在外观->小部件->页面->左侧边栏中在排除页面中放置了一些页面ID。 But these pages still exist in sidebar which is not to. 但是这些页面仍然存在于侧边栏,而没有。

Link to site 链接到网站

Here's the code of left sidebar 这是左侧边栏的代码

 <?php 
 global $post, $accesspress_ray_options;
 $accesspress_ray_settings = get_option( 'accesspress_ray_options',    $accesspress_ray_options );
if(is_front_page()){
$post_id = get_option('page_on_front');
}else{
$post_id = $post->ID;
}
$post_class = get_post_meta( $post_id, 'accesspress_ray_sidebar_layout', true );

if($post_class=='left-sidebar' || $post_class=='both-sidebar' ){
?>
<div id="secondary-left" class="widget-area left-sidebar sidebar">
    <?php if ( is_active_sidebar( 'left-sidebar' ) ) : ?>
        <?php dynamic_sidebar( 'left-sidebar' ); ?>
    <?php endif; ?>
</div><!-- #secondary -->
<?php } ?>

The right approach at this would be to create custom page templates. 正确的方法是创建自定义页面模板。 So that you can have page templates with sidebar and without sidebar. 这样您就可以拥有带有侧栏和不带侧栏的页面模板。

Read more about it here 在这里了解更多

You can entirely copy your page.php and define the following to it. 您可以完全复制page.php为其定义以下内容。

<?php
/*
Template Name: No Sidebar Page Template
*/

And make sure you don't have the get_sidebar() in the new template. 并确保新模板中没有get_sidebar()

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

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