WordPress.org

Support

Support » Themes and Templates » [Resolved] How to remove the nav bar in 2010?

[Resolved] How to remove the nav bar in 2010?

  • Hello all,

    I’d like to create a new page template in the TwentyTen theme. The only difference is that this new page will not have a Navigation Bar. How can I create this template? How can I make WordPress allow me to pick it when I create a new page?

    Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator Michael

    @alchymyth

    Forum Moderator

    as the menu is in header.php, you could either use a conditional statement there (sort of if(is_page_template('mytemp.php')) : )

    http://codex.wordpress.org/Function_Reference/is_page_template

    or use css and the body class to make the menu hidden on this page template, for instance:
    .page-template-mytemp-php #access { display: none; }

    to assign the page template to a new page, see the ‘attribute’ field on the left of the ‘pages’ in admin.

    The navigation bar is in the header.php and not in the different page files.

    As you are saying that you want to hide the menu for a single template rather than a specific page, another way would be to move the navigation bar code into a template part, and add this in each page file.

    So you would remove the ‘access’ block of code from the header.php, paste this in a new file called navigation-1.php, then in the different page files, like index.php, archive.php, single.php, page.php, search.php, add a call to the menu.

    in the different page files after the get_header()

    <?php /* Get our navigation bar */ ?>
    <?php get_template_part( 'navigation', 1 ); ?>

    This tutorial on adding a second menu may help!

    If you are not using a child theme then you may want to look at the other tutorials and posts.

    HTH

    David

    Rewind, brain now working, just use a custom header.

    1. Open the header.php file and save this as header-custom.php.

    2. remove the lines (81-86):

    <div id="access" role="navigation">
     <?php /*  Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?>
    	<div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div>
    	<?php /* Our navigation menu.  If one isn't filled out, wp_nav_menu falls back to wp_page_menu.  The menu assiged to the primary position is the one used.  If none is assigned, the menu with the lowest ID is used.  */ ?>
    	<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
    </div><!-- #access -->

    3. Create the template page.

    4. Change:
    get_header(); ?>
    to
    get_header('custom'); ?>

    HTH

    David

    Thanks Adeptris! I have done all that. However, when I go to create a new page, I don’t see my new page template as an option. How can I get WordPress to put my custom page on the drop-down menu?

    Moderator Michael

    @alchymyth

    Forum Moderator

    does your page template have all the criteria as described in
    http://codex.wordpress.org/Pages#Page_Templates

    particular something like this at the start:

    <?php
    /*
    Template Name: No Navigation Page
    */
    ?>

    Yes indeed – it says this at the beginning, since I just modified the original page template:

    <?php
    /**
    * The template for displaying all pages.
    *
    * This is the template that displays all pages by default.
    * Please note that this is the WordPress construct of pages
    * and that other ‘pages’ on your WordPress site will use a
    * different template.
    *
    * @package WordPress
    * @subpackage Twenty_Ten
    * @since Twenty Ten 1.0
    */

    Right now WordPress gives me two options when I create a new page: “Default Template” and “One column, no sidebar”. How do I tell wordpress that I have a new Page Template option?

    Change that to something like below, you have to tell WordPress this is a custom template page by giving it a name, as in the reply by alchymyth.

    <?php
    /**
    Template Name: No Navigation Page
    *
    * The custom template with no navigation.
    *
    * @package WordPress
    * @subpackage Twenty_Ten
    * @since Twenty Ten 1.0
    */
    get_header('custom'); ?>

    HTH

    David

    It worked! Thanks guys 🙂

    Great can you mark this topic resolved, please!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] How to remove the nav bar in 2010?’ is closed to new replies.