• Resolved blondie53185

    (@blondie53185)


    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!

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    Thread Starter blondie53185

    (@blondie53185)

    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]

    Thread Starter blondie53185

    (@blondie53185)

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

    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).

    Thread Starter blondie53185

    (@blondie53185)

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘php to remove header & navigation from Twenty-Eleven child theme’ is closed to new replies.