• Resolved marimbaman

    (@marimbaman)


    Hello, I am running WP 3.8.1 with Trim theme and 1.4.3 Polylang plugin. The static page is used, default language is English. Permalinks settings are: https://gran-guitar.com/sample-post/
    Polylang settings: The language is set from the directory name in pretty permalinks and Remove /language/ in pretty permalinks, options are chosen. Media and Synchronization options are all activated. There are two menus for each language, Ru and En, every page has a corresponding translated version.

    The goal is to have a menu in corresponding language on top of the page, i.e. if I call the Russian version of the page, the menu switches to Russian and stays that way.
    Same applies for English.
    As it is now, however, the menu switches back to English whenever another menu item is called. I am really stuck here and would appreciate some constructive pointers. All suggestions such as switching back to general theme etc didn’t work so far. Here is the link to the site in question:
    Thank you.

    https://www.ads-software.com/plugins/polylang/

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

    (@chouby)

    Your theme probably suffers a very frequent bug.
    Please go in the theme code and look for the instruction register_nav_menu and wp_nav_menu and report their parameters here.

    Thread Starter marimbaman

    (@marimbaman)

    Thank you for quick reply. Here is the excerpt from header.php :

    <?php do_action('et_header_menu'); ?>
    
    					<nav id="main-menu">
    						<?php
    							$menuClass = 'nav';
    							if ( get_option('trim_disable_toptier') == 'on' ) $menuClass .= ' et_disable_top_tier';
    							$primaryNav = '';
    							if (function_exists('wp_nav_menu')) {
    								$primaryNav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'echo' => false ) );
    							}
    							if ($primaryNav == '') { ?>
    								<ul class="<?php echo esc_attr( $menuClass ); ?>">
    									<?php if (get_option('trim_home_link') == 'on') { ?>
    										<li <?php if (is_home()) echo('class="current_page_item"') ?>><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php esc_html_e('Home','Trim') ?></a></li>
    									<?php }; ?>
    
    									<?php show_page_menu($menuClass,false,false); ?>
    									<?php show_categories_menu($menuClass,false); ?>
    								</ul>
    							<?php }
    							else echo($primaryNav);
    						?>
    					</nav>

    and from functions.php:

    function register_main_menus() {
    	register_nav_menus(
    		array(
    			'primary-menu' => __( 'Primary Menu', 'Trim' )
    		)
    	);
    }
    if (function_exists('register_nav_menus')) add_action( 'init', 'register_main_menus' );

    Plugin Author Chouby

    (@chouby)

    Your code looks good ??

    I went back to your site and it seems that the problem is now fixed. Am I right?

    Thread Starter marimbaman

    (@marimbaman)

    Not quite, unfortunately. If you switch to Russian, the menu does switch to the Russian version, too. But it doesn’t remain a Russian one if you proceed to another menu item, it switches back to English.
    The goal is to have a Russian menu active as long as I move around in Russian section of the page.
    What could be a cause of this behaviour and how to fix it?

    Plugin Author Chouby

    (@chouby)

    Oh I see. The problem is that you did not create menu item with Russian pages but with English pages. You must change your menu items in your Russian menu and slect Russian pages.

    Thread Starter marimbaman

    (@marimbaman)

    You must change your menu items in your Russian menu and slect Russian pages.
    And how do I go about it, precisely, I’m a bit confused as to where to change this?

    Thread Starter marimbaman

    (@marimbaman)

    Now, I got it, thank you so very much. Your help is very appreciated.

    Thread Starter marimbaman

    (@marimbaman)

    You must change your menu items in your Russian menu and slect Russian pages.
    And how do I go about it, precisely, I’m a bit confused as to where to change this?
    This still stands true, the changes I made didn’t work. So how can I fix this issue?

    Plugin Author Chouby

    (@chouby)

    In Appearance->menus, you have to create one menu per language. Let’s say ‘menu_en’ and ‘menu_ru’.
    In ‘menu_en’, you add English pages and the language switcher. In ‘menu_ru’, you add Russian pages and the language switcher.
    Then, once menus are both saved, you click on ‘manage locations’ tab and you assign ‘menu_en’ to ‘Primary menu English’ and ‘menu_ru’ to ‘Primary menu Русский’.

    Thread Starter marimbaman

    (@marimbaman)

    Thank you so much. It works just fine.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Menus don't switch according to languages’ is closed to new replies.