• 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

    (@webbhelp)

    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.