WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to remove the nav bar in 2010? (11 posts)

  1. mkpoway
    Member
    Posted 3 years ago #

    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!

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    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.

  3. Digital Raindrops
    Member
    Posted 3 years ago #

    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

  4. Digital Raindrops
    Member
    Posted 3 years ago #

    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

  5. mkpoway
    Member
    Posted 3 years ago #

    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?

  6. alchymyth
    Forum Moderator
    Posted 3 years ago #

    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
    */
    ?>
  7. mkpoway
    Member
    Posted 3 years ago #

    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
    */

  8. mkpoway
    Member
    Posted 3 years ago #

    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?

  9. Digital Raindrops
    Member
    Posted 3 years ago #

    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

  10. mkpoway
    Member
    Posted 3 years ago #

    It worked! Thanks guys :)

  11. Digital Raindrops
    Member
    Posted 3 years ago #

    Great can you mark this topic resolved, please!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags