Add a second menu to WordPress

Add a second menu to WordPress

WordPress 3.0 and above introduced the menu editor, which gave users a means to customize the automatically generated menu. Whilst this kind of functionality brings WP closer to being a full content management system, the framework is still far off from that point. Here, we’ll look at extending the menu system by adding a second editable menu into the default WordPress template, Twenty Twelve.

Note: If you are using twenty twelve for this exercise, you’ll need to create a child theme to prevent any updates to the template overwriting our modifications.

1. In your theme’s functions.php file, place the code below, you’ll need to change header-menu and Header Menu to something else, e.g. footer-menu and Footer Menu

function register_my_menus() {
  register_nav_menus(
    array( 'header-menu' => __( 'Header Menu' ) )
  );
}
add_action( 'init', 'register_my_menus' );

2. Next you need to add some PHP code into your theme’s template, where you want the menu to appear, as follows:

<?php wp_nav_menu( array( 'theme_location' => 'footer-menu', 'container_class' => 'footer-styling-class' ) ); ?>

The container class adds a class to our new menu so we can target it with CSS styles

http://codex.wordpress.org/Navigation_Menus

Oliver Partridge

Building websites since 2000, I have a wealth of experience in eMarketing, SEO, e-mail marketing and social media marketing. Google+ and Twitter

Leave a Reply


  • Your Weight Loss Challenge Website Build

    Portfolio

    www.yourweightlosschallenge.co.uk Situation The client is a distributor of Herbalife products. A 12-week slimming challenge course is to be offered with the ability for people to

  • How to get Google star reviews and ratingsHow to get Google star reviews and ratings

    How to get Google star reviews and ratings

    Website Design & Development

    I have been working to get star ratings and avatars in google result pages for the sites I do at work. The result is that

  • hosted-shopping-cart.com revealed

    Portfolio

    Latest product from Tring Web Design is www.hosted-shopping-cart.com, an affiliate site for BigCommerce, a hosted and managed ecommerce solution that provides an easy way to