• Resolved aitax85

    (@aitax85)


    Hi! thanks for the wonderful plugin
    I have the same problem. The menu wouldn’t change with the language. It stays the default one. Post and everything else translate correctly but the menu stays the same.
    In the header the menu is set like this:

    <nav id="mobile-navigation" class="top-navigation" role="navigation">
    
    	<?php $anyMenu = get_terms( 'nav_menu' ) ? true : false;
        	  $menuSelect = get_theme_mod('tesseract_tho_header_menu_select');
    
    		if ( $anyMenu && ( ( $menuSelect ) && ( $menuSelect !== 'none' ) ) ) :
    			wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'header-menu' ) );
    		elseif ( $anyMenu && ( !$menuSelect || ( $menuSelect == 'none' ) ) ) :
    			$menu = get_terms( 'nav_menu' );
    			$menu_id = $menu[0]->term_id;
    			wp_nav_menu( array( 'menu_id' => $menu_id ) );
    		elseif ( !$anyMenu ) :
    			wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) );
    		endif; ?>
    
    </nav><!-- #site-navigation -->

    I’m not an PHP expert and i read some thread concerning this issue but i cannot sort things out. Hope in someone’s help.

    My Settings:
    – Home static Page
    – Language is set from content
    – Remove language in pretty permalink
    – When the front page is visited set the language according to the browser preference
    – Activate languages and translations for media
    – Permalink set by “Post Name”
    – Menus are set correctly (one menu per language)

    my website’s http://www.gbwebtech.com/ (work in progress…)

    sorry for posting on the wrong topic earlier.
    Thank you

    https://wordpress.org/plugins/polylang/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chouby

    (@chouby)

    Hi!

    Did you solve your problem? It seems to work for me.

    However, this line is correct:

    wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) );

    But these two are not:

    wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'header-menu' ) );
    wp_nav_menu( array( 'menu_id' => $menu_id ) );

    So depending on the results of the tests, it will or will not work.
    Any theme which does not precise “theme_location” in wp_nav_menu is buggy. See also: https://polylang.wordpress.com/2014/04/10/incorrect-usage-of-wp_nav_menu/

    Thread Starter aitax85

    (@aitax85)

    I found the problem whit the code. I had already tried to change that but it gave me an PHP error. There were two line that needed to be changed.
    Now it works! Thank you for helping. Compliments for the plugin!!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Menu won't change language’ is closed to new replies.