How To Add Custom Menu Support in Your WordPress Theme

Page 1

How To Add Custom Menu Support in Your WordPress Theme Coding Made Easy For Wordpress

To learn more information about this topic visit: My Brave True Hero

Brought to you by: My Brave True Hero - http://www.mybravetruehero.com

Page 1


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' )) ); } Brought to you by: My Brave True Hero - http://www.mybravetruehero.com

Page 2


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-menuclass', '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.

Brought to you by: My Brave True Hero - http://www.mybravetruehero.com

Page 3


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/

Brought to you by: My Brave True Hero - http://www.mybravetruehero.com

Page 4


To learn more information about this topic visit: My Brave True Hero

Brought to you by: My Brave True Hero - http://www.mybravetruehero.com

Page 5


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.