Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1289435

    Hello,

    I am using Polyang to have 2 different versions of my website.
    For the mobile menu, I have some small differences compared to desktop versions.

    I am using this code: https://kriesi.at/support/topic/polylang-and-different-mobile-menus/#post-1271395 to show different menu’s.

    //show different mobile menu's according to language
    if ( wp_is_mobile() ) {
    function replace_wp_nav_menu( $args ){
    	if (get_locale() == 'en_US') {
    		$args['menu'] =  401;
    	}
    	else {
    		$args['menu'] =  375;
    	}
    	return $args;
    }
    add_filter( 'wp_nav_menu_args', 'replace_wp_nav_menu', 10, 2 );
    }

    But, the mobile version of the menu it is shown also for the footer and in the menu above the header.
    I want to show a different mobile menu only for the main menu.
    How can I change the code to achieve this, please ?

    #1289997

    Nobody ?

    #1290752

    Hi,
    Sorry for the very late reply, the mobile menu is created from the regular menu that is created in the WordPress menu option, it is not really another menu, so you should create a footer menu and a secondary menu, which is the menu used above the header and not shown on mobile, and then your two main menus for each language which will also be used for mobile menus.

    Best regards,
    Mike

    #1292050

    Hi,

    The way you describe it, is the way that I have made it.
    However, the menu above the header and the footer menu, using the function above, is replaced with the main menu.
    You can check the google cached version of my website to understand it better. Please see private links.

    #1292117

    Hi,
    I checked your homepage again in my browser dev tools mobile emulation in both languages and included a screenshot below. So while I can tell the footer is different, the top bar looks the same to me in both languages. Can you post a screenshot of what is meant to be shown?

    Best regards,
    Mike

    #1294909

    The problem is that the mobile menu (ID=401 and ID=375 as in the code above) it is replacing the footer menu.
    Do the footer menu should stay the same for desktop and mobile.

    Please see the screenshot.

    #1295001

    Hi,
    I believe it is your Polyang plugin that is changing your footer menu based on language, if you want to use the same footer menu for both languages then you will need to make this selection within the Polyang / menu options.
    The menu IDs above are not for the footer menus.

    Best regards,
    Mike

    #1295619

    Without that piece of code in the functions.php, everything works good. So, it is not from Polylang.
    Anyway, I solved the problem in the following way:
    – I have selected the “Alternate Menu for Mobile” form Enfold theme option.
    – I have reduced the code in functions.php to use the menu only fo English language.

    #1296189

    Hi longip,

    Thanks for the update. So everything is working as it should now then? Please let us know if you should need any further help on the topic.

    Best regards,
    Rikard

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.