0

Ok, I'm creating a wordpress theme. I don't want my navigation menu to show in the home page "Only" if the site admin setup Front page displays > A static page (select below).

otherwise I want to show the menu in home page & other pages too. I've used this <?php if(!is_front_page()):?> function, but it is not working.

some one suggest me "<?php if(!is_home()):?>", but it is not working either.

So how do I make it work?

Full code:

<?php if(!is_home()):?>
    <!-- NAVIGATION START -->
    <div id="navigation">
        <nav class="navbar navbar-custom" role="navigation">
              <div class="container">
                    <div class="row">
                          <div class="col-sm-2">
                              <div class="site-logo">
                                <a href="index.html" class="brand">ajax</a>
                              </div>
                          </div>                          

                          <div class="col-sm-10"> 

                              <!-- Brand and toggle get grouped for better mobile display -->
                              <div class="navbar-header">
                                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#menu">
                                    <i class="fa fa-bars"></i>
                                </button>
                              </div>
                              <!-- Collect the nav links, forms, and other content for toggling -->
                              <div class="collapse navbar-collapse" id="menu">
                                <?php wp_nav_menu( array( 
                                'theme_location' => 'secondary', 
                                'menu_class' => 'nav navbar-nav navbar-right', 
                                'fallback_cb' => 'false' 
                                )); ?>
                              </div>
                              <!-- /.Navbar-collapse -->

                          </div>
                    </div> <!--bootstrap row end-->
              </div> <!--bootstrap container end-->
        </nav>
    </div> 
    <!--NAVIGATION END -->
    <?php endif;?>
13
  • What template file are you using for the home page? Index.php, home.php, or front-page.php? Oct 15, 2014 at 9:39
  • I'm using index.php Oct 15, 2014 at 9:53
  • Hmmm. It seems !is_home() should work. Interesting... Oct 15, 2014 at 9:55
  • I've added the full code, could you check please & tell me if I'm doing anything wrong? Oct 15, 2014 at 10:00
  • Hint: Use the plugin Debug Objects to find, which Conditional Tag was fired on this page.
    – bueltge
    Oct 15, 2014 at 10:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.