March 18

Modify Theme To Support WordPress Menus Checklist

0  comments

This checklist outlines the steps you need to take to make a theme support WordPress menus. If you get turned around try watching the video first.

One

Find where the menu is going to be. Most of the time it is your header but remember you can put these custom menus anywhere in your design.

Open the file in your theme where the menu is going to be. In this case, header.php
Find where the current header is and replace it with this code:

Two

Open your theme’s functions.php file and add this code before the closing ? > tag.

// Add nav_menu
if ( function_exists( 'register_nav_menu' ) ) {
  register_nav_menu('hdr_nav', 'Header Navigation');
}

Now save both of them and re-upload to your site if you need to.

Three

Log in to WordPress as Admin and navigate to the Menu screen. You should see the option to use the theme locations.

Optional

To target a specific menu – not as user friendly but theme developer has control over what menu used:

wp_nav_menu( array('menu' => 'Header menu2') );

Optional

Remove the container sometimes to be compatible with the theme

wp_nav_menu( array('container' => '') );

Optional

Sometimes you want separators in between your menu items you can do that by using after or before link like this:

wp_nav_menu( array('after' => '·') );

Optional

Sometimes you want separators inside the link but before the text. You can use this code:

wp_nav_menu( array('link_before' => '»') );

If you have more than one menu you can group them all together and use this function in your theme’s functions.php file instead:

if ( function_exists( 'register_nav_menus' ) ) {
     register_nav_menus(
          array(
            'hdr_menu' => 'Header Menu',
            'ftr_menu' => 'Footer Menu'
          )
     );
}

Just be sure to fix up your header and footer or wherever this menu will appear and use the wp_nav_menu tag like this:

wp_nav_menu(array('theme_location'=>'hdr_menu'));

or

wp_nav_menu(array('theme_location'=>'hdr_menu'));

Notice the location ID must match whatever you entered in functions.php


Tags

menu, theme, WordPress


You may also like

Force cPanel Password Reset

Force cPanel Password Reset
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Get in touch

Name*
Email*
Message
0 of 350