WordPress.org

Ready to get started?Download WordPress

Forums

Is it possible to hide menu completely in home page? (4 posts)

  1. mdivk
    Member
    Posted 2 years ago #

    I want to use an introduction page as my homepage, so I don't want to show any menu on it.

    Is it possible? is there any plugin doing that?

    Thanks.

  2. Gary Darling
    Member
    Posted 2 years ago #

    You could use a built-in WordPress function to test whether the page being viewed is the Front Page, hide the menu if it is, then show the menu if it is not the front page. This requires some php coding, so you will need to get comfortable with that.

    Not knowing how your menu in inserted, here is an example that works with the default Twenty Eleven theme, inside the header.php file:

    <?php if ( is_front_page() ) {
            echo 'Foo';
            }
    	else
    	{
                 wp_nav_menu( array( 'theme_location' => 'primary' ) );
    	}
    ?>

    The wp_nav_menu code is how WP adds the custom menu to the page; by wrapping it in an if / else construct you are testing whether we are on the front page, if we are, send the popular Foo statement instead of the menu (you can also echo an empty string to eliminate the space where the menu would be). Assuming you have given the user a way to get deeper into the site (off the front page), the else construct kicks in and shows the menu on all other pages & posts.

  3. mdivk
    Member
    Posted 2 years ago #

    Thank you for your reply.

    I am using Graphene theme, I don't know PHP programming, could you please take a look at the theme and tell me how to make changes?

    Thank you very much.

  4. mdivk
    Member
    Posted 2 years ago #

    Thank you for enlightening, I got it working.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags