Support » Theme: Customizr » Second Menu?

  • Is there an easy way to create a second (or even third) menu that would be controllable from the menus toolbar in the dashboard?

    I would like the menu to appear either/both above the logo and in the footer area.

    Thanks in advance!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You need to register it with register_nav_menu:

    add_action( 'init', 'register_matts_menu' );
    function register_matts_menu() {
        if ( function_exists( 'register_nav_menu' ) ) {
            register_nav_menu( 'matts-top-menu', 'Top Menu' );
        }
    }

    If you want to register more than one, change register_nav_menus above to array:

    register_nav_menus(array(
                'matts-top-menu' =>  'Top Menu',
                'matts-footer-menu' =>  'Footer Menu'
            )
        );

    Than hook wp_nav_menu to where you want it displayed. I hooked this one above the logo/title display:

    add_filter('tc_logo_title_display', 'display_matts_top_menu');
    function display_matts_top_menu($output) {
    	return ( has_nav_menu( 'matts-top-menu' ) ? wp_nav_menu (
            array (
                'theme_location' => 'matts-top-menu',
    			'container_id'    => 'top-menu',
    			'container_class'    => 'menu pull-right'
            )
        ).'<div class="clearall"></div>' : '' ).$output;
    }

    And, of course, you need to style it a bit. As a basic example, I floated this one right, added some |’s between the items and small-ed the font-size.

    #top-menu ul li {
    	display: inline-block;
    	float: left;
    	list-style-type: none;
    	font-size: small;
    	}
    #top-menu ul li:before {
    	content: " | ";
    	}
    #top-menu ul > li:first-child:before {
    	content: none;
    	}

    If you’re using multiple levels you’ll need to style it some more, maybe add some carets and use the walker class to apply TBs classes to it, since they’re already embedded in the theme.

    That’s about it.

    To whoever moderated this topic:

    I have posted a thorough answer to this question some 10-12 hours ago. Took me almost half an hour to document and test (I usually don’t spend more than 10 minutes on a support answer). Was it deleted? If yes, I’d like to know why.

    Thank you.

    Looks like it was caught in the spam catcher – and probably accidentally deleted – when there’s a big backlog of spam, it happens sometimes. I’ve undeleted it.

    Thank you, WPyogi. Really didn’t want to write it again. Is there a way I could avoid this happening again?

    Hi acub, thank you for this explanation
    Can you tell me, which file I have to edit, to register the new menu with register_nav_menu? is it function.php?
    thanks!

    Yes, all php goes inside functions.php of your child theme, which should not be a copy of it’s parent counterpart. If this is the first custom code you add to functions.php of your child theme, open a blank file, put the code below in it and save it as functions.php in your child theme’s folder.

    <?php
    add_action( 'init', 'register_matts_menu' );
    function register_matts_menu() {
        if ( function_exists( 'register_nav_menu' ) ) {
            register_nav_menu( 'matts-top-menu', 'Top Menu' );
        }
    }
    
    add_filter('tc_logo_title_display', 'display_matts_top_menu');
    function display_matts_top_menu($output) {
    	return ( has_nav_menu( 'matts-top-menu' ) ? wp_nav_menu (
            array (
                'theme_location' => 'matts-top-menu',
    			'container_id'    => 'top-menu',
    			'container_class'    => 'menu pull-right'
            )
        ).'<div class="clearall"></div>' : '' ).$output;
    }

    The CSS (4th snippet) goes inside the child theme’s style.css or the custom CSS panel in theme options.
    After this, you need to go to menus and select an existing menu (or create a new one if you need it) for the newly created menu location and save.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Second Menu?’ is closed to new replies.