How to add a secondary menu in WordPress

This article was written by in November 1, 2013, & may not be posted on other sites!
Original source url for this article: How to add a secondary menu in WordPress

How to add secondary menu in WordPress.
By default WordPress displays the primary menu as the main menu in most Wordress themes, All new pages are automatically added to this default primary menu. If you need a custom menu or how to add a secondary menu in WordPress, this is how to:

How to add a secondary menu in WordPress

How to add a secondary menu in WordPress

To add a secondary menu in WordPress you should be working with a childtheme. This is how to do it:

  1. Open the functions.php or create the file if you don’t already have it your childtheme. Add this code to enable a secondary menu in the WordPress admin (don’t forgett the <?php tags if you need to add them):
    //add a secondary menu
    register_nav_menus( array(
    'primary' => __( 'Primary Menu', 'CHILDTHEMENAME' ),
    'secondary' => __( 'Secondary Menu', 'CHILDTHEMENAME'),
    ) );
  2. Save and upload the functions.php to your child theme. This will add the choice of a secondary menu in WordPress admin > appearance > menus > manage locations. However, you need to add a custom menu to be able to choose it.
  3. Add a custom menu in WordPress admin > appearance > menus and choose it to be the secondary menu in WordPress admin > appearance > menus > manage locations.
  4. To show the menu on your website you need to add this code below somewhere in your child theme, for example in the header.php. Use this php code to show the secondary menu inside a div with class “custom-menu”:
    <?php //print the menu
    wp_nav_menu( array('container_class' => 'custom-menu',
    'theme_location' => 'secondary' ) ); ?>

 

How to add a custom menu WordPress:

  1. Log in to the WordPress Admin and go to appearance > menus
  2. “Create new menu” and name it. Save the menu by clicking the button “create menu”.
  3. You will see panels on the left: pages / categories / links. Just open a panel for example “pages” to see all created pages on your site (use the “view all” tab). Simply check and “add to menu”.
  4. To see all panels avalable, use the > “Screen Options” tab on the top-right to also see Tags, Posts and more,
  5. Create an external link in the panel “Links”.
  6. Or add a category to the menu using the “Category” panel and so on.

    How to add a secondary menu in WordPress

  7. You can drag and drop all menu items in the menu to suit your needs.

    How to add a secondary menu in WordPress

  8. You can add menu items inside other menu items. this will create a dropdown sub menu.
  9. When you are done, save the menu.
  10. To make your custom the default main menu , check the box “primary menu” or go to the “Manage locations” tab. Choose your primary menu and your secondary menu. Save.

You are done!

 

Spread the word

Facebooktwittergoogle_pluslinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *