WordPress.org

Ready to get started?Download WordPress

Forums

How do I take the header off of one page template? (12 posts)

  1. INORHAR
    Member
    Posted 2 years ago #

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    I am trying to take the header off of one of my page templates and it keeps doing something weird like making the page larger than life, but the header is off. I basically don't want the top menu showing on a certain page template. Any suggestions? This is the current code I have.

    <?php
    /*
    Template Name: Fullwidth Page
    */
    ?>
    <?php get_header(); ?>
    <!--Start Contetn wrapper-->
    <div class="grid_24 content_wrapper">
         <!--Start Fullwidth-->
         <div class="fullwidth">
              <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
              <h1>
                   <?php the_title(); ?>
              </h1>
              <?php the_content(); ?>
              <?php comments_template(); ?>
              <!--End comment Section-->
         </div>
         <div class="bigshadow"></div>
         <!--End Fullwidth-->
         <?php endwhile;?>
    </div>
    <!--End Content wrapper-->
    <div class="clear"></div>
    </div>
    <?php get_footer(); ?>

    This is the part I already tried taking out <?php get_header(); ?> but it did that thing I mentioned earlier. Please help!

  2. Andrew
    Forum Moderator
    Posted 2 years ago #

    You could use a conditional statement around the header not to show on a particular page.
    E.g

    <?php
    if (! $page->ID == 99 ) {
     get_header();
    }
    ?>

    The integer 99 being the actual ID of the page you don't want the header shown.

  3. potentweb
    Member
    Posted 2 years ago #

    Modify the header.php and use conditional in the part you want to not show. There are important files in the header so if you remove the whole header.php, your going to loose your CSS file and other important files.

  4. webbrewers
    Member
    Posted 2 years ago #

    Or create a page template, identify the element you want to hide and add this to the template:
    <style>#theelementtobehidden{display:none;}</style>.

  5. Andrew
    Forum Moderator
    Posted 2 years ago #

    Or create a page template, identify the element you want to hide and add this to the template:
    <style>#theelementtobehidden{display:none;}</style>.

    This way the header will load and be visible at first, but then hide.

    INORHAR,
    Using the same underlying logic, you could apply this style to your stylesheet.

  6. webbrewers
    Member
    Posted 2 years ago #

    He mentioned the "top menu" so that would be the only element to hide. Plus in my experience the hidden element won't be visible at all on page load. Still, I agree the conditional statement is a better option and I'd only do it this way if he's not able to do that.

  7. INORHAR
    Member
    Posted 2 years ago #

    Where am I putting the conditional statement? Am I taking this out <?php get_header(); ?>

    I tried putting the conditional statement in and the header was still there and then I took the portion above out with the condiotional statement in and the page went completely haywire and too big. I want the page to look the exact same but without the header showing. What am I doing wrong?

  8. Andrew
    Forum Moderator
    Posted 2 years ago #

    Post the code you have tried.

  9. INORHAR
    Member
    Posted 2 years ago #

    This one did nothing:

    <?php
    /*
    Template Name: Fullwidth Page
    <style>#header{display:none;}</style>.
    */
    ?>
    <?php get_header(); ?>
    <?php
    if (! $page->ID == 245/2 ) {
     get_header();
    }
    ?>
    <!--Start Contetn wrapper-->
    <div class="grid_24 content_wrapper">
         <!--Start Fullwidth-->
         <div class="fullwidth">
              <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
              <h1>
                   <?php the_title(); ?>
              </h1>
              <?php the_content(); ?>
              <?php comments_template(); ?>
              <!--End comment Section-->
         </div>
         <div class="bigshadow"></div>
         <!--End Fullwidth-->
         <?php endwhile;?>
    </div>
    <!--End Content wrapper-->
    <div class="clear"></div>
    </div>
    <?php get_footer(); ?>

    And I tried this one but the page went super big but the header was off

    <?php
    /*
    Template Name: Fullwidth Page
    <style>#header{display:none;}</style>.
    */
    ?>
    <?php
    if (! $page->ID == 245/2 ) {
     get_header();
    }
    ?>
    <!--Start Contetn wrapper-->
    <div class="grid_24 content_wrapper">
         <!--Start Fullwidth-->
         <div class="fullwidth">
              <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
              <h1>
                   <?php the_title(); ?>
              </h1>
              <?php the_content(); ?>
              <?php comments_template(); ?>
              <!--End comment Section-->
         </div>
         <div class="bigshadow"></div>
         <!--End Fullwidth-->
         <?php endwhile;?>
    </div>
    <!--End Content wrapper-->
    <div class="clear"></div>
    </div>
    <?php get_footer(); ?>
  10. Please put your code in backticks.

  11. Andrew
    Forum Moderator
    Posted 2 years ago #

    This

    if (! $page->ID == 245/2 ) {
     get_header();
    }

    Is saying, "if the page id is not 122.5, get the header".
    I think you want to be trying this

    if (! $page->ID == 245 || ! $page->ID == 2 ) {
     get_header();
    }
  12. alchymyth
    Forum Moderator
    Posted 2 years ago #

    btw, WordPress has its own function to conditionally check for pages:
    http://codex.wordpress.org/Function_Reference/is_page

    to repeat what @potentweb
    already mentioned
    - you cannot simply remove the 'get_header();' code; the header contains a lot of essential coding for your site to work properly.

    you could call a custom header template instead;
    for instance create a header-empty.php template, edit it to remove any visible elements which you do not want in those pages, and call it conditionally with:

    <?php
    if ( is_page( array(245,2) ) ) { get_header('empty'); }
    else { get_header(); }
    ?>

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

Topic Closed

This topic has been closed to new replies.

About this Topic