当前位置: 动力学知识库 > 问答 > 编程问答 >

wordpress - How to remove header from particular single page

问题描述:

I'm a newbie at WordPress and php.

I want to remove the header from one or two pages only.

I saw this http://wordpress.org/support/topic/how-to-remove-footer-from-individual-pages

so I did this in my header.php file found under my theme folder

 <?php if( !is_page('18') ) :?> <!-- this is what I added -->

<header class="banner">

...rest of html...

</header>

<?php endif;?> <!-- this is what I added -->

Just for the sake of seeing if changes to this file were taking effect I also did <?php if( false ) :?> which was supposed to remove it from all pages but this didn't work either.

Though I don't know the difference, I saw some different syntax and so also tried <?php if(false) { ?> and <?php } ?>

I am wondering if I have to do something else to have the changes take effect.

In case it matters, I am using the roots starter theme http://roots.io/starter-theme/

and WordPress 3.9.1

网友答案:

You should be editing the file /roots/templates/header-top-navbar.php. This get decided at base.php:

if (current_theme_supports('bootstrap-top-navbar')) {
    get_template_part('templates/header-top-navbar');
} else {
    get_template_part('templates/header');
}

Just in case, add your code to both. I tested your code with header-top-navbar.php and works ok.

网友答案:

you are giving wrong condition it should be if(is_page('18')) {// do nothing } else {...rest of html...}

分享给朋友:
您可能感兴趣的文章:
随机阅读: