{"id":109079,"date":"2017-03-27T09:34:49","date_gmt":"2017-03-27T08:34:49","guid":{"rendered":"https:\/\/www.megamenu.com\/documentation\/different-menu-on-mobile-copy\/"},"modified":"2017-06-26T17:35:34","modified_gmt":"2017-06-26T16:35:34","slug":"custom-theme-integration","status":"publish","type":"ht_kb","link":"https:\/\/www.megamenu.com\/documentation\/custom-theme-integration\/","title":{"rendered":"How do I get Max Mega Menu to work in my custom theme?"},"content":{"rendered":"<p>There are no special requirements to get Max Mega Menu working with your custom theme, you only need to make sure you use the core WordPress functions to register and display your menu correctly.<\/p>\n<h3>Step 1 &#8211; Register a Menu Location<\/h3>\n<p>Use the <a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/register_nav_menu\">register_nav_menu<\/a> or <a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/register_nav_menus\">register_nav_menus<\/a> function to add a new menu location to your theme.<\/p>\n<p>Add the following to your themes <strong>functions.php<\/strong> file:<\/p>\n<pre class=\"lang:default decode:true \">function register_my_menu() {\r\n  register_nav_menu( 'my_new_location', 'My New Location' );\r\n}\r\nadd_action( 'after_setup_theme', 'register_my_menu' );<\/pre>\n<p><strong>Important<\/strong>: Make a note of the menu location ID. In the code above it is &#8220;<strong>my_new_location<\/strong>&#8220;.<\/p>\n<h3>Step 2 &#8211; Output the menu location in your theme<\/h3>\n<p>Use the <a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/wp_nav_menu\">wp_nav_menu<\/a> function to output the menu.<\/p>\n<p>Add the following to one of your\u00a0theme template files (usually header.php):<\/p>\n<pre class=\"lang:default decode:true\">wp_nav_menu( array( 'theme_location' =&gt; 'my_new_location') );<\/pre>\n<p><strong>Important<\/strong>: the &#8220;theme_location&#8221; parameter must be present, and must match the menu location ID specified in step 1. wp_nav_menu takes many parameters, but the only one <strong>required<\/strong> for Max Mega Menu to work is &#8220;theme_location&#8221;.<\/p>\n<p>Once these steps have been taken follow the standard <a href=\"https:\/\/www.megamenu.com\/documentation\/installation\/\">documentation<\/a> to enable Max Mega Menu for your menu.<\/p>\n<h3>Troubleshooting<\/h3>\n<ul>\n<li>Make sure your menu location ID is identical\u00a0in both your &#8220;register_nav_menu&#8221; and &#8220;wp_nav_menu&#8221; function<\/li>\n<li>Avoid using hyphens (-) in the location ID, use underscores instead<\/li>\n<li>Make sure the &#8220;wp_nav_menu&#8221; function call specifies the correct &#8220;theme_location&#8221; parameter<\/li>\n<li>If you have changed the menu location ID since enabling MMM for a location, you will need to re-enable MMM for your new location\u00a0ID<\/li>\n<li>Make sure your theme follows WordPress coding standards (and correctly includes <a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/wp_head\">wp_head<\/a> and <a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/wp_footer\">wp_footer<\/a>).<\/li>\n<\/ul>\n<h3>Sample Custom Theme<\/h3>\n<p><a href=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2017\/03\/justamenu.zip\">Download Sample Theme<\/a><\/p>\n<p>The sample theme has the bare minimum code required for Max Mega Menu to work correctly. The menu location is registered in functions.php and output in index.php.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are no special requirements to get Max Mega Menu working with your custom theme, you only need to make sure you use the core WordPress functions to register and display your menu correctly. Step 1 &#8211; Register a Menu Location Use the register_nav_menu or register_nav_menus function to add a&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"ht-kb-category":[14],"ht-kb-tag":[],"class_list":["post-109079","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-faqs"],"uagb_featured_image_src":[],"uagb_author_info":{"display_name":"Tom Hemsley","author_link":"https:\/\/www.megamenu.com\/author\/megamenu\/"},"uagb_comment_info":0,"uagb_excerpt":"There are no special requirements to get Max Mega Menu working with your custom theme, you only need to make sure you use the core WordPress functions to register and display your menu correctly. Step 1 &#8211; Register a Menu Location Use the register_nav_menu or register_nav_menus function to add a...","_links":{"self":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/109079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/comments?post=109079"}],"version-history":[{"count":8,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/109079\/revisions"}],"predecessor-version":[{"id":117482,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/109079\/revisions\/117482"}],"wp:attachment":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/media?parent=109079"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb-category?post=109079"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb-tag?post=109079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}