Deprecated: Required parameter $location follows optional parameter $post_types in /home1/mybravet/public_html/wp-content/plugins/monarch/monarch.php on line 3783

Warning: session_start(): Session cannot be started after headers have already been sent in /home1/mybravet/public_html/wp-content/themes/Divi Child Theme/header.php on line 1
How To Add Custom Menu Support in Your WordPress Theme | WordPress Developer Philippines How To Add Custom Menu Support in Your WordPress Theme | WordPress Developer Philippines
Select Page

Ever wanted to use the drag and drop feature in WordPress? But the problem is that your theme doesn’t support custom menu. Here is what you need to do

1. First you need to locate or go to your theme’s folder and add this code before the closing “?>” in your functions.php

If you see in the code we are trying to register two places the header and the footer menu

/* Register Menus*/
function register_my_menus() {
register_nav_menus(
array('header-menu'=> __('Header Menu'), 'footer-menu'=> __('Footer Menu'))
);
}
add_action('init','register_my_menus' );

And when that is done hit save and we are half way done

2. Now the next part is that we are going to locate where we want the navigation to be placed. Go to your theme’s folder again and add this code in your header.php file

<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'header-menu-class', 'menu' => 'header-menu') ); ?>

Important:

1. ‘menu’ => ‘header-menu’ code is what we place if you want to target the header but if you want the footer you can just set it like this ‘menu’ => ‘footer-menu’

2. ‘container class’ => ‘header-menu-class’ this is for the style for the menu so this one ‘header-menu-class’ is like a class in your CSS file which will look like this #header-menu-class

If everything is good save it and that is it your theme now supports custom menu in WordPress so you can now start organizing your menus with ease by dragging and dropping the pages or categories.

The codes that I used were not mine but found that it’s a very good example so I would like to acknowledge the author Alastair McDermott and you can visit him at http://www.websitedoctor.com/

Pin It on Pinterest

Share This