Title: Theme_location does not work
Last modified: August 21, 2016

---

# Theme_location does not work

 *  [webbhelp](https://wordpress.org/support/users/webbhelp/)
 * (@webbhelp)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/theme_location-does-not-work/)
 * Hi!
 * I am trying to use 2 menus in one page(all pages), header and footer menu.
    The
   problem is that my wordpress is broken or maybe I am. It does not work whatever
   I do, I have tried everything.
 * This is the last I tried:
 *     ```
       add_action( 'init', 'my_custom_menus' );
       function my_custom_menus() {
       	register_nav_menus(
       			array(
       					'primary-menu' => __( 'Primary Menu' ),
       					'secondary-menu' => __( 'Secondary Menu' )
       			)
       	);
       }
       ```
   
 * before that I used:
 *     ```
       //register_nav_menu('huvudmeny', 'Headermeny');
       //register_nav_menu('footermeny', 'Footermeny');
       ```
   
 * It get registered (both codes), I can see it in admin, appearance -> menus.
 * The problem is: I cannot show it on the page.
    I use this in the Header: `<?php
   wp_nav_menu (array('theme_location' => 'primary-menu','menu_class' => 'nav'));?
   >`
 * And this in the footer:
    `<?php wp_nav_menu (array('theme_location' => 'secondary-
   menu','menu_class' => 'nav'));?>`
 * Nothing shows.
 * If I try:
 *     ```
       <?php if ( has_nav_menu( 'primary-menu' ) )
       				echo 'primary-menu exists';
       		?>
   
       		<?php if ( has_nav_menu( 'secondary-menu' ) )
       			echo 'secondary-menu exists';
       		?>
       ```
   
 * I got those messages, but still no menu.
 * What is wrong? pls find it, because I can’t
 * Thanks

Viewing 1 replies (of 1 total)

 *  Thread Starter [webbhelp](https://wordpress.org/support/users/webbhelp/)
 * (@webbhelp)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/theme_location-does-not-work/#post-5003086)
 * I found one problem:
 *     ```
       add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
       function your_custom_menu_item ( $items, $args ) {
       	if ($args->theme_location == 'primary-menu'){
       		return '<li id="logo"><a href="'. home_url( '/' ) .'" class="logo"><img src="'. get_bloginfo('template_url') .'/assets/images/logo.png" alt="'. esc_attr( get_bloginfo( 'name', 'display' ) ) .'"></a></li>'. $items;
       	}
       ```
   
 * I am using a filter to add a `<li>` before the menu is rendered.
    This works 
   now because I change to a correct name.
 * But the secondary menu does not show up?

Viewing 1 replies (of 1 total)

The topic ‘Theme_location does not work’ is closed to new replies.

## Tags

 * [not work](https://wordpress.org/support/topic-tag/not-work/)
 * [theme_location](https://wordpress.org/support/topic-tag/theme_location/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [webbhelp](https://wordpress.org/support/users/webbhelp/)
 * Last activity: [11 years, 12 months ago](https://wordpress.org/support/topic/theme_location-does-not-work/#post-5003086)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
