WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How do I remove header menu from HOME page only? (7 posts)

  1. treadlightly
    Member
    Posted 2 years ago #

    Hello!

    I am using the free minimatica theme and have made some changes to it.

    in header.php i have added:

    <nav id="access" role="navigation">
    <?php wp_nav_menu( array( 'theme_location' => 'header_nav', 'container_id' => 'header-nav', 'container_class' => 'nav', 'fallback_cb' => 'minimatica_nav_menu' ) ); ?>
    </nav><!-- #access -->

    which added a navigation menu to my header. it is perfect but i want to hide it from the HOME page and only show it on all other pages.

    is there any way to do this?

  2. Wrap the menu in a conditional tag. Try:

    <?php if ( !is_front_page() ): ?>
    
    <nav id="access" role="navigation">
    <?php wp_nav_menu( array( 'theme_location' => 'header_nav', 'container_id' => 'header-nav', 'container_class' => 'nav', 'fallback_cb' => 'minimatica_nav_menu' ) ); ?>
    </nav><!-- #access -->
    
    <?php endif; ?>

    This says "if it's NOT the homepage, display the menu."

    More about conditional tags: http://codex.wordpress.org/Conditional_Tags

  3. treadlightly
    Member
    Posted 2 years ago #

    OH MY GOODNESS, this is exactly what i needed.
    it worked absolutely perfectly.

    THANK YOU SO MUCH for your help!

    you rock!

  4. Excellent! Glad it worked out. Conditional tags are awesome. :-)

  5. tfc
    Member
    Posted 1 year ago #

    Hi, I'm trying to do the opposite thing. I want my nav menu only on the pages that have my "front page template" applied, but not on all the other pages. Here is what I have in my header.php

    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <title><?php wp_title(); ?></title>
    <?php wp_head(); ?>
    </head>
    <body id="<?php prima_option('themelayout') ?>" <?php body_class(); ?>>
    <?php if(prima_get_option('usernav')&&class_exists('WP_eCommerce')) get_template_part( 'flexi-usernav' ); ?>
    <div id="flexi-wrapper">

    What do I change to get it to only show my nav on the home page?

    Thanks so much!

  6. bcworkz
    Member
    Posted 1 year ago #

    I'm guessing at how your nav gets generated, but this should be close:

    <?php
    if ( is_front_page() ) {
      if(prima_get_option('usernav')&&class_exists('WP_eCommerce'))
      get_template_part( 'flexi-usernav' );
    }
    ?>
  7. opusxxvii
    Member
    Posted 1 year ago #

    I have similar needs. I want to create a custom template for individual image gallery pages. However, since these are pages for clients who wish to show these to their clients, I want to exclude any signs of my site's identity, ie. page should have no logo, no menu, nothing except for the gallery.

    Creating a custom template is fairly clear to me, but it seams I may need to either customize my header file or even create a separate, custom header file dedicated to this template.

    Please advise...thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags