Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1269565

    Dear Enfold team,

    I added Polylang to a website with the Enfold theme and everything is working fine so far, except that the mobile menu (different from the desktop menu) that is supposed to show up after clicking the burger shows up empty as you can see in the website attached as private.

    1. How can I make it show up and moreover, how can I make it different for English and Spanish (in both cases, the main menu is not the exact same one for desktop and mobile views)?

    2. How can I display the language options next to the social menu bar instead of the main one?

    Thanks for your support,

    #1269957

    Hey Esteban,
    Sorry for the very late reply, so you are trying to use a different menu for the mobile menu than the desktop menu? Enfold doesn’t have an option to use a different menu for mobile, so could you please include an admin login so we can examine how you are trying to achieve this.

    Best regards,
    Mike

    #1270594

    Hi Mike,

    Thanks for your answer. I formerly (before translation) had a mobile menu set up in Enfold>Main Menu>General>Alternate Menu for Mobile that was slightly different from the main menu. After this, I installed Polylang, translated the website but realized that the mobile menu does not show up anymore and I get an empty overlay instead in both languages (Spanish and English).
    My goal now is to keep the same setting as before, but for both languages as follows:

    1. Spanish website desktop: Spanish menu desktop version
    2. Spanish website mobile: Spanish menu mobile version
    3. English website desktop: English menu desktop version
    4. English website mobile: English menu mobile version

    Here below I am providing credentials to access the website. Feel free to test anything you consider since this is not the production website. Thanks for your help!

    #1271163

    Hi,
    Sorry for the late reply and thanks for explaining further. I found this function for changing the Alternate Menu for Mobile as explained in this thread.
    I tried testing this on my localhost with Polylang and changed it to show a menu based on the language, in this example I set one menu to show for English and another menu to show for any other language. In $header[‘alternate_menu’] there is the ID of your selected menu. Replace the value with your translated menu ID according to your language.
    To find the ID of your other menus look at the bottom of any menu move your cursor over the “Delete” link and in the popup for the link you find something like http://localhost/wp_xxx/wp-admin/nav-menus.php?action=delete&menu=25&_wpnonce=xxx
    menu=25: 25 is the id of the menu.
    Try adding this code to the end of your functions.php file in Appearance > Editor:

    function my_header_setting_filter( $header, $context )
    {
    	if (get_locale() == 'en_US') {
    	$header['alternate_menu'] = 11;
    	}
    	else {
    		$header['alternate_menu'] = 56;	
    	}
    	
    	return $header;
    }
    add_filter( 'avf_header_setting_filter', 'my_header_setting_filter', 10, 2 );

    So in the above code you will want to adjust the language, ‘en_US’ and the two IDs

    Best regards,
    Mike

    #1271214

    Hi Mike,

    Thanks for your help. Unfortunately I added the code but the mobile menus are still empty. Are there any additional settings that must be disabled or changed? You can see the code I added with the same credentials I posted privately before. Basically, I want the Main Menu (Mobile EN) whose id is 93, to show with the language en_US and Main Menu (Mobile ES) whose id is 24, to show with the language es_CL

    All the best,
    Esteban

    #1271240

    Hi,
    Thank you for the feedback, I took a look at how you have this set up and it seems identical to my localhost test, I tried disabling the function and the Alternate Menu for Mobile option and the desktop main menus are shown for the correct languages, but when the Alternate Menu for Mobile option is enabled the menus are not shown.
    I also found that your server is still using PHP v5.6.4, this could be the cause, please update to PHP v7.4

    There might also be the option to adjust your desktop menus to display different items in the mobile menu, this could be a workaround if you are not able to update your PHP.
    This method is about adding custom classes to your menu items and using CSS to hide or show based on language.

    Best regards,
    Mike

    #1271244

    Hi Mike,

    I tried the same website on localhost in order to change the PHP version rapidly and even after switching to PHP 7.4.12 I still get the same results (please see the video privately attached). Regardless if I set Alternate Menu for Mobile to Do not use an alternate menu for mobile or if I choose the previously selected menu, I still see a blank mobile menu (I emptied cache and tried a few browsers to double-check).

    What else may I be missing? Also what would be the way to accomplish this as you mention through CSS? I would ideally want to avoid any hard-coded menus if possible (I can think of doing it with ::before/::after selectors and media queries, but would probably not be ideal)

    Thanks for your help,
    Esteban

    #1271395

    Hi,
    Thank you for the feedback video, and I’m glad that you are able to test PHP 7.4.12, so as that didn’t work I can’t think of what else might be causing the blank mobile menu, since this is working on my localhost.
    At this point the next step would be to disable everything, plugins, scripts, etc, and see if the mobile menu still shows blank, and then start enabling the plugins and script one at a time until the error is found, you could try this on your localhost.
    I did some testing on my localhost and I found a way to replace the main menus based on language with this function:

    function replace_wp_nav_menu( $args ){
    	if (get_locale() == 'en_US') {
    		$args['menu'] =  34;
    	}
    	else {
    		$args['menu'] =  56;
    	}
    	return $args;
    }
    add_filter( 'wp_nav_menu_args', 'replace_wp_nav_menu', 10, 2 );

    I was pretty excited when I got this to work, but I was not able to add a reliable screen size check to it so I was not able to target the mobile menu directly with this.

    Anyways, I also tried the css solution and it works good, this is what I did, I noticed that the only difference between your English desktop menu and the mobile menu was two custom menu items, Facebook & Instagram, I added these two to your desktop menu with the custom class “mobileonly”:
    2021-01-10_152613.jpg
    then I added this css to your Quick CSS:

    @media only screen and (min-width: 990px) { 
    	.mobileonly {
    		display: none !important;
    	}
    }

    So now the two extra menu items show only on the English mobile menu, please check, if you like this then try to add the two items to your other desktop menu.
    So with this setup you are only using the two desktop menus, one for each language, and the Alternate Menu for Mobile is disabled so they also show on mobile, with the extra items.

    Best regards,
    Mike

    #1275331

    Hi Mike,

    Sorry for the late response. This solution did the trick and it’s good enough for the website since as you noticed, I just needed to append a couple of entries to the menu.

    Thanks a lot!
    All the best,
    Esteban

    #1275389

    Hi,

    I’m glad this was resolved. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Polylang and different mobile menus’ is closed to new replies.