Reply To: Changing the Position of the Elements in the Navbar

#22995
Daniel Tara
Keymaster

Unfortunately the code above alone is not going to work. Here’s a reliable way to add a second navigation menu:

1. If you haven’t already, go ahead and create a child theme.

2. In the child theme’s directory add a file called functions.php and the following code to it:

function enlightenment_child_register_secondary_navigation() {
    register_nav_menu(
        'secondary',
        __( 'Secondary Menu', 'enlightenment' )
    );
}
add_action( 'after_setup_theme', 'enlightenment_child_register_secondary_navigation' );

function enlightenment_child_secondary_navigation() {
	if( ! doing_action( 'enlightenment_after_header' ) ) {
		return;
	}

    wp_nav_menu();
}
add_action( 'enlightenment_after_header', 'enlightenment_child_secondary_navigation', 1 );

function enlightenment_child_secondary_nav_menu_args( $args ) {
    if( ! doing_action( 'enlightenment_after_header' ) ) {
        return $args;
    }

    $args['theme_location']  = 'secondary';
    $args['container_class'] = 'secondary-navigation';
    $args['container_id']    = 'secondary-navigation';
    $args['walker']          = '';

    return $args;
}
add_action( 'wp_nav_menu_args', 'enlightenment_child_secondary_nav_menu_args', 22 );

You will most likely still need to style the navigation using custom CSS.