Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #831151

    Good morning,
    I’m using Uber menu in addition to Enfold theme in my amastone.com and amastone.it website.

    With last Enfold update, I liked the new mobile menu so I want to use Uber menu on desktop and Enfold menu on mobile.
    Because of Uber menu, If I use Enfold menu in mobile, I see the Uber menu advanced items like “tab-menu” and “column”.
    I already tried to hide the element using some plugins, but if I hide the advanced elements, also the child elements will be hide.

    So I thought to create a second menu without Uber menu advanced items and load this different menu in mobile using PHP (I have a child theme for Enfold).

    Please could you help me?

    #831175

    Hi,

    Please add following code to Functions.php file of your child theme in Appearance > Editor

    function av_different_mobile_menu( $args = '' ) {
    
    if(wp_is_mobile()) { 
    	$args['menu'] = 'main-menu-mobile';
    } else { 
    	$args['menu'] = 'main-menu';
    } 
    	return $args;
    }
    add_filter( 'wp_nav_menu_args', 'av_different_mobile_menu' );

    and change menu names(“main-menu-mobile” and “main-menu”) as needed :)

    Best regards,
    Yigit

    #831998

    Hi Yigit,
    thanks for the quick reply.

    The code works, but it change also the menu in the pre-header (I use it for Login / Register). How can I exclude it?

    EDIT:
    I added an IF to change only the main menu. This is the final code:

    function av_different_mobile_menu( $args = '' ) {
    	if($args['menu_id'] == 'avia-menu') {
    		if(wp_is_mobile()) {
    			$args['menu'] = 'main-menu-mobile';
    		} else {
    			$args['menu'] = 'main-menu';
    		}
    	}
    	return $args;
    }
    add_filter( 'wp_nav_menu_args', 'av_different_mobile_menu' );

    Is this ok or there is a more efficient way?

    • This reply was modified 7 years, 4 months ago by integraing.
    #832112

    Hi,

    Yes, that is okay! Glad you figured it out and thanks for sharing your solution for future readers!

    For your information, you can take a look at Enfold documentation here – http://kriesi.at/documentation/enfold/
    And if there are features that you wish Enfold had, you can request them and vote the requested ones here – https://kriesi.at/support/enfold-feature-requests/
    For any other questions or issues, feel free to post them here on the forum and we will gladly try to help you :)

    Best regards,
    Yigit

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Load different menu for mobile via PHP’ is closed to new replies.