WordPress.org

Ready to get started?Download WordPress

Forums

Dynamic Menus (3 posts)

  1. Demetrius Pop
    Member
    Posted 1 year ago #

    I'm developing locally, and I have added this code to my functions file:

    add_action( 'init', 'register_my_menus' );
    function register_my_menus() {
    	register_nav_menus(
    		array(
    			'primary-menu' => __( 'menu-top' ),
    			'secondary-menu' => __( 'Secondary Menu' ),
    			'footer-menu' => __( 'Footer Menu' )
    		)
    	);
    }

    I have added this code to my header file:

    <?php wp_nav_menu( array( 'theme_location' => 'menu-top', 'container_class' => 'my menu' ) ); ?>

    Am I filling in the correct information and in the correct locations? menu-top is the menu I have created in appearance > menus, and mymenu is the style sheet that I am trying to link to.

  2. Demetrius Pop
    Member
    Posted 1 year ago #

    Sorry, I thought I had everything within the code block :(

  3. kbellagio
    Member
    Posted 1 year ago #

    The add_action goes after the function call via: http://codex.wordpress.org/Navigation_Menus

    So it should look like this

    function register_my_menus() {
    	register_nav_menus(
    		array(
    			'primary-menu' => __( 'menu-top' ),
    			'secondary-menu' => __( 'Secondary Menu' ),
    			'footer-menu' => __( 'Footer Menu' )
    		)
    	);
    }
    add_action( 'init', 'register_my_menus' );

    Hope that helps!

Topic Closed

This topic has been closed to new replies.

About this Topic