• I’m running an old theme on 3.6 and I’m trying to introduce WP 3.0 menus to the mix. I’ve created a custom page template and dedicated header.php (header2.php) for testing. I’ve made sure to add the necessary code to functions.php:

    add_action( 'init', 'register_my_menus' );
    
    function register_my_menus() {
    	register_nav_menus(
    		array(
    			'primary-menu' => __( 'Primary Menu' ),
    			'secondary-menu' => __( 'Secondary Menu' ),
    			'tertiary-menu' => __( 'Tertiary Menu' )
    		)
    	);
    }

    and header2.php:

    <?php wp_nav_menu( array( 'theme_location' => 'primary-menu' ) ); ?>

    However, even without styling the menu in CSS, I’m not getting the defined menu I created in Appearance>Menus which I’ve called “Primary Menu”, instead I’m getting an ordered list of all pages. In addition, I’m still getting the “Your theme does not natively support menus, but you can use them in sidebars by adding a “Custom Menus” widget on the Widgets screen.” message…

    Any ideas on what I’m missing here?

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You don’t need an add_action. Just this:

    register_nav_menus(
    		array(
    			'primary-menu' => __( 'Primary Menu' ),
    			'secondary-menu' => __( 'Secondary Menu' ),
    			'tertiary-menu' => __( 'Tertiary Menu' )
    		)
    	);

    Thread Starter darkmatter661

    (@darkmatter661)

    Thanks Peter_L, but no change!

    Try to remove the localization, so:
    'primary-menu' => 'Primary Menu',

    I’m not seeing any other possible errors.

    Thread Starter darkmatter661

    (@darkmatter661)

    So I replaced it with this?

    register_nav_menus(
    		array(
    			'primary-menu' => 'Primary Menu',
    			'secondary-menu' => 'Secondary Menu',
    			'tertiary-menu' => 'Tertiary Menu'
    		)
    	);

    …no change.

    Thread Starter darkmatter661

    (@darkmatter661)

    Oh sorry, you meant in the header?? Let me try that…

    No, I meant in the functions.php. This is weird. Are you sure you’re actually using the header2.php file. Try renaming it to header-test.php and call it like this get_header(‘test’) on your test template.

    Or simpler, just try and call <?php wp_nav_menu( array( ‘theme_location’ => ‘primary-menu’ ) ); ?> from your page template.

    Thread Starter darkmatter661

    (@darkmatter661)

    Definitely using header-2.php and calling it with <?php get_header('2'); ?>

    But, I did add <?php wp_nav_menu( array( ‘theme_location’ => ‘primary-menu’ ) ); ?> to the bottom of my template and it produced the same menu, being all pages, ordered.

    I’m as baffled as you…

    I remember having some problems with this last time I used it but I forgot how I solved this. Perhaps try a single menu first, so, register_nav_menu. Perhaps try and rebuild your menu.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Navigation Menu question’ is closed to new replies.