WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] php to remove header & navigation from Twenty-Eleven child theme (6 posts)

  1. blondie53185
    Member
    Posted 3 years ago #

    I have created a child theme from the Twenty Eleven theme. What code would I need to put into the functions.php file (in the child) in order to remove my custom header image and navigation bar from my landing pages? I have already used some php to remove the Twenty Eleven default header images from the site and use my own custom header.

    Any clue will be appreciated - I've searched this forum, Google and W3C Schools and just don't get it.

    Thanks!

  2. Nikki Blight
    Member
    Posted 3 years ago #

    If I'm understanding your intent correctly, I think that's something I would handle in the header.php file rather than the functions.php file.

    <?php
    if($post->ID != XX) {
         //code to display nav menu goes here
    }
    ?>

    where XX is the ID of the page or post you do not want the menu to appear on. The same basic structure would apply to code for the header image.

  3. blondie53185
    Member
    Posted 3 years ago #

    Thank you for the response. You are correct when you say it should go into the header.php file but I still do not understand where it should go. Here is a portion of my coding if you could explain a little more:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  4. blondie53185
    Member
    Posted 3 years ago #

    I hope I got this pastebin thing right: http://pastebin.com/MFhiVfpm

  5. Nikki Blight
    Member
    Posted 3 years ago #

    For the navigation menu, unless removing it from the layout affects your design, I'd just put it around the entire nav tag (lines 36 through 57 in your pastebin):

    <?php if($post->ID != XX): ?>
         <nav id="access" role="navigation">
             ...code truncated for the sake of space
         </nav><!-- #access -->
    <?php endif ;?>

    If you need the nav tag for layout's sake, you can just put the if conditional around line 56:

    <?php
    if($post->ID != XX) {
         wp_nav_menu( array( 'theme_location' => 'primary' ) );
    }
    ?>

    If I'm reading your code right, you can remove the header the same way by putting the if conditional around lines 5 through 20 (the hgroup tag).

  6. blondie53185
    Member
    Posted 3 years ago #

    Thank you so much. You give very good instructions! I do understand this now. :)

Topic Closed

This topic has been closed to new replies.

About this Topic