WordPress.org

Ready to get started?Download WordPress

Forums

Placed a TwentyTen nav bar in a Kubrick theme, custom menus disappear (32 posts)

  1. David Borrink
    Member
    Posted 2 years ago #

    I placed the code for a TwentyTen navigation bar in a Kubrick-based theme, and it works fine, but... when I choose to create a custom menu from the dashboard, the nav bar disappears.

    The nav bar works fine with the existing page hierarchy set up by setting order numbers in the pages dashboard, and using parent and child pages.

    I made sure I had the dashboard menus functions copied over from TwentyTen's function.php page, so that allowed the menu functions to appear in the dashboard of my Kubrick-based theme, but when I chose to activate a custom menu setup I made..... poof, the nav bars disappear.

    Any idea what I need to do? I looked in the TwentyTen functions page for more functions but I'm not seeing them.

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    You copied everything over from the header.php too?

  3. David Borrink
    Member
    Posted 2 years ago #

    Yes, I copied this

    <div id="access" role="navigation">
    				<?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>

    from TwentyTen's header.php and put in my theme's header.php

  4. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    That's not everything from header.php...

  5. David Borrink
    Member
    Posted 2 years ago #

    Oh, I see this addtional bit of code

    <?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>

    that I stripped out because it was "Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff"

    Is that critical to the nav bar?

  6. David Borrink
    Member
    Posted 2 years ago #

    Okay, I put the full "access" code from TwentyTen's header.php into my theme's header.php and now I get "Skip to content" in the nav bar in a top row, then the pages listed in the second row. I choose my custom menu, and the second row disappears. All I'm left with is the "skip to content" to the left in the nav bar.

  7. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    well, you need to bring over all the related css as well, if you are bringing in twentyten's menu setup

    The css hides that skip to content business, which is for screen readers and meant to be hidden'

    It also controls dropdown behaviour, etc

  8. David Borrink
    Member
    Posted 2 years ago #

    Ah, I'll look through the TwentyTen CSS and see what I missed. I did pick up the whole "menu" section of the CSS but obviously there's a few other "access" areas I need to pick up.

  9. David Borrink
    Member
    Posted 2 years ago #

    Okay I found a @media print tag in the CSS, and I found a Mobile Safari item, too which had "access" as the div. I added those related sections to the CSS of my Kubrick-based theme, but I"m still getting the "Skip to content" info in the nav bar.

    Any ideas? Thanks for your time RevVooDoo.

  10. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    /* Text meant only for screen readers */
    .screen-reader-text {
    	position: absolute;
    	left: -9000px;
    }

    you get this guy? from just above the header section

  11. David Borrink
    Member
    Posted 2 years ago #

    Okay, that bit of code got rid of the "skip to content" message, but I'm still left without a custom menu listing. The nav bar dissapears. Again, if I use none as a custom menu, I get the default page order in the nav menus. But choosing a custom menu makes the nav bar disappear.

    In the TwentyTen CSS, here are two sets of code I didn't copy over that relate to the "access" div (and these are shortened examples to only show what's relevant to "access":

    /* =Mobile Safari ( iPad, iPhone and iPod Touch )
    -------------------------------------------------------------- */
    ......
    
    #access,
    .entry-meta,
    .entry-utility,
    .navigation,
    .widget-area {
    	-webkit-text-size-adjust: 120%;
    
    }

    and

    /* =Print Style
    -------------------------------------------------------------- */
    
    @media print {
    	....
    	#access,
    	#branding img,
    	#respond,
    	.comment-edit-link,
    	.edit-link,
    	.navigation,
    	.page-link,
    	.widget-area {
    		display: none !important;
    	}
    
    }

    Are these critical to making the custom menus work? I pasted these relevant parts in and the page structure got messed up.

  12. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    Nope, that is pretty self explanatory....styling for mobile browsers, and for print

    So, you have this business from header.php:

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

    and you register the menu in functions.php

    // This theme uses wp_nav_menu() in one location.
    	register_nav_menus( array(
    		'primary' => __( 'Primary Navigation', 'twentyten' ),
    	) );

    and I'm pretty confident we have the css right, so now we create our custom menu in the menu editor, and then we assign our new custom menu to the Primary position

    Is that all correct? If so.... it really should be working

  13. David Borrink
    Member
    Posted 2 years ago #

    Well it's still not working for some reason, and I copied your two bits of code there just to make sure.

  14. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    Do you have any plugins going or anything? I would test without any plugins active....

    Something is causing a conflict now, gotta try to pin that down.

  15. David Borrink
    Member
    Posted 2 years ago #

    I turned off all plugins, and the problem persists. So it's not a plug-in issue, apparently.

  16. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Have you added support for custom menus in functions.php?

  17. David Borrink
    Member
    Posted 2 years ago #

    I read the link you mentioned and I added a few things in. Here's what I added to my functions.php file....

    // This theme uses wp_nav_menu() in one location.
    	register_nav_menus( array(
    		'primary' => __( 'Primary Navigation', 'twentyten' ),
    	) );
    
    	add_action( 'init', 'register_my_menus' );
    
    	add_theme_support( 'menus' );

    I'm not versed in the proper syntax for adding functions so I don't know if I have this right. The above items are in but I have no menus. Am I missing a colon or parenthesis in this setup?

    And do I need 'twentyten' in there? I'm putting this in a Kubrick theme.

  18. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    It looks correct but you can drop the , 'twentyten' in register_nav_menus. Can you post a url for this site?

  19. David Borrink
    Member
    Posted 2 years ago #

    I removed the 'twentyten'. The site is http://brightideaspress.com/ I have the custom menu selected. The nav bar should be just below the logo and tagline and above the slide show.

  20. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    add_theme_support( 'menus' ) should be removed

    I wonder if that is causing the conflict?

    register_nav_menus takes care of adding the menus, in terms of support

    the add_theme_support is not needed, maybe causing issues?

  21. David Borrink
    Member
    Posted 2 years ago #

    Esmi's link to the codex says, "Then you need to ensure that the theme turns these menu options on, so you need this bit of code as well -

    add_action( 'init', 'register_my_menus' );"

    It implies that a custom theme needs this. I'm a real rookie when it comes to adding actions.

  22. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    correct, you need that part

    this:

    // This theme uses wp_nav_menu() in one location.
    	register_nav_menus( array(
    		'primary' => __( 'Primary Navigation', 'twentyten' ),
    	) );
    
    	add_action( 'init', 'register_my_menus' );

    Does the same thing as this:

    add_theme_support( 'menus' );

    so in effect, you are doing it twice

    add_theme_support( 'menus' );

    should be removed

  23. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    @Rev: You're right. My bad - but it won't stop custom menus from being generated, as far as I recall. However, I'm not seeing the skip link markup within #access either.

  24. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    where does register_my_menus being added to init come from? It hasn't been defined.....

  25. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    function register_my_menus() {
         register_nav_menus( array(
                 'primary' => __( 'Primary Menu' )
         ) );
    }
    
    add_action( 'init', 'register_my_menus' );

    something like that maybe?

  26. David Borrink
    Member
    Posted 2 years ago #

    It's on there, but nothing is happening.

    Esmi, what is the skip link markup?

  27. David Borrink
    Member
    Posted 2 years ago #

    I should clarify... I just did Rev. Voodoo's code example a couple posts up, and put it in the site. No vagueness allowed. :-)

  28. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    ?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>

    From what Rev posted earlier.

  29. David Borrink
    Member
    Posted 2 years ago #

    That's in my header.php. Here's what I have in header.php:

    <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 -->
  30. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    If you check your home page's source code, you'll see that:

    <div class="skip-link screen-reader-text"><a href="#content" title="Skip to content">Skip to content</a></div>

    is not in the generated markup for the page. But it should be according to the code you posted above. Not trying to state the obvious here but are you absolutely sure that you're editing the right header.php file?

Topic Closed

This topic has been closed to new replies.

About this Topic