Title: Problem in menu after hooking
Last modified: March 29, 2022

---

# Problem in menu after hooking

 *  [hesamfisher](https://wordpress.org/support/users/hesamfisher/)
 * (@hesamfisher)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/problem-in-menu-after-hooking/)
 * Hi guys.
    i’ve got a problem menu after hooking to wordpress. I customized my
   menu by this code in header
 *     ```
       <header>
               <div class="container">
                 <div class="brand">
                   <a href="http://hesamstudio.com"><h2>Hesam<span>Studio</span></h2></a>
                 </div>
   
                 <div class="mobile-nav">
                   <a href="#" class="open-menu">MENU</a>
                 </div>
                 <nav class="navbar">
                     <ul class="menu">
                     <li class="menu-item">
                       <a href="https://www.hesamstudio.com">Home</a>
                     </li>
                     <li class="menu-item">
                       <a href="<?php echo get_template_directory_uri(); ?>/about.html">About</a>
                     </li>
   
                     <li class="menu-item">
                       <a href="#">Contact</a>
                     </li>
   
                     <li class="menu-item has-sub-menu">
                       <a href="#">Portfolio</a>
   
                       <ul class="sub-menu">
                         <li class="menu-item">
                           <a href="<?php echo get_template_directory_uri(); ?>/illustration.html">Illustration</a>
                         </li>
   
   
                         <li class="menu-item">
                           <a href="<?php echo get_template_directory_uri(); ?>/bookillustration.html">Book Illustration</a>
   
                         </li>
   
                         <li class="menu-item">
                           <a href="#">Portrait Design</a>
                         </li>
                         <li class="menu-item">
                           <a href="#">Sketches</a>
   
                         </li>
                       </ul>
                     </li>
   
                   </ul>
   
                   <a href="#" class="close-menu">Close Menu</a>
                 </nav>
   
               </div>
             </header>
       ```
   
 * after hooking by this code in function.php
 *     ```
       <?php
           function theme_setup(){
               add_theme_support('title-tag');
               register_nav_menus(array(
                   'Main_Menu'=>'menu',
               ));
           }
           add_action("after_setup_theme","theme_setup");
       ?>
       ```
   
 * and changing header code to below my menu theme doesn’t work properly and in 
   wordpress after adding sample menu it doesn’t show home and other menu which 
   has been added.
 *     ```
       <header>
               <div class="container">
                 <div class="brand">
                   <a href="http://hesamstudio.com"><h2>Hesam<span>Studio</span></h2></a>
                 </div>
   
                 <div class="mobile-nav">
                   <a href="#" class="open-menu">MENU</a>
                 </div>
                 <nav class="navbar">
                    <?php wp_nav_menu(array(
                            'theme_location' => 'Main_Menu',
                            'depth' => '3',
                         )); ?>
   
                   <a href="#" class="close-menu">Close Menu</a>
                 </nav>
   
               </div>
             </header>
       ```
   
    -  This topic was modified 4 years, 2 months ago by [hesamfisher](https://wordpress.org/support/users/hesamfisher/).
    -  This topic was modified 4 years, 2 months ago by [hesamfisher](https://wordpress.org/support/users/hesamfisher/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fproblem-in-menu-after-hooking%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/problem-in-menu-after-hooking/#post-15511167)
 * I tested the WP specific part of your code and it works fine on my test site.
   Be sure you’ve selected your menu under “Manage locations” tab. It’s possible
   to add a menu in the back end but never assign it to a location.
 * Or your issue could simply be caching. Try flushing all caches involved, both
   client and server side before deciding there’s a problem with your code.
 * It doesn’t seem to matter in this case, but by convention FWIW, internal tags
   or handles used by WP PHP code (`'Main_Menu'` in your case) should follow slug
   naming rules — all lower case and only `-` non-alpha-numeric character. While`'
   Main_Menu'` does work, it’d be better as `'main-menu'`. By consistently doing
   so, you avoid strange bugs in situations where it really does matter. The user
   visible label `'menu'` can be any string you care to use.

Viewing 1 replies (of 1 total)

The topic ‘Problem in menu after hooking’ is closed to new replies.

## Tags

 * [_](https://wordpress.org/support/topic-tag/_/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/problem-in-menu-after-hooking/#post-15511167)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
