Home>Support>Hide menu on mobile; Vantage

Hide menu on mobile; Vantage

Hi, I would to hide completely menu in php on mobiles. So I wrote this, but it doesn’t work

 <?php if ( wp_is_mobile() ) {
     <div id="logo"></div>
} else {
     wp_nav_menu( array( 'main' => 'site-main' ) );
} 
?>

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 8 years, 7 months ago Alex S
    Hi, I Work Here

    Hi Vladislav,

    You can change this with some custom CSS. If you navigate to AppearanceCustom CSS, you’ll get our custom CSS editor. Just add the following code.

    .so-vantage-mobile-device .site-navigation {
        display: none;  
    }
    

    While you can do this with PHP, I wouldn’t recommend it as it’s kind of overkill.

    You might also need to install the SiteOrigin CSS Editor.

  2. 8 years, 7 months ago Vlad Skull

    That’s i know, but dont want to use… I just want ot disable menu in header.php or menu for mobile.

  3. 8 years, 7 months ago Alex S
    Hi, I Work Here

    Hi Vladislav,

    That’s fine. As always we recommend the use of a child theme when making changes to theme files. Here’s a basic child theme for Vantage already set up.

    Make a copy of the file vantage/parts/masthead.php, and open it. Find: get_template_part( ‘parts/menu’ and replace that line with the following PHP.

    <?phpif( ! wp_is_mobile() ){    	get_template_part( 'parts/menu', apply_filters( 'vantage_menu_type', siteorigin_setting( 'layout_menu' ) ) );}?>
  4. 8 years, 7 months ago Vladislav F

    Thx Man <3 As I want.

  5. 8 years, 7 months ago Vladislav F

    so this is the final code for masthead.php

    <?php
    if( ! wp_is_mobile() ){
        	get_template_part( 'parts/menu-empty', apply_filters( 'vantage_menu_type', siteorigin_setting( 'layout_menu' ) ) );
    
    } else {
    get_template_part( 'parts/menu', apply_filters( 'vantage_menu_type', siteorigin_setting( 'layout_menu' ) ) );
    }
    ?>

    But still have trouble when I try to delete ‘vantage_menu_type’…

  6. 8 years, 7 months ago Alex S
    Hi, I Work Here

    Hi Vladislav,

    Could you elaborate on the trouble you’re experiencing?

  7. 8 years, 7 months ago Vladislav F

    the code working after I deleted ‘vantage_menu_type’, But it working in opposite verse. On desktop there is no menu meanwhile on mobile there is… So I tried to invert etc, but the same thing.

  8. 8 years, 7 months ago Alex S
    Hi, I Work Here

    Hi Vladislav,

    Based on what you’ve described you should use the following code instead.

    <?php
    if( wp_is_mobile() ){
        get_template_part( 'parts/menu-empty', apply_filters( 'vantage_menu_type', siteorigin_setting( 'layout_menu' ) ) );
    } else {
        get_template_part( 'parts/menu', apply_filters( 'vantage_menu_type', siteorigin_setting( 'layout_menu' ) ) );
    }
    ?>
    
  9. 8 years, 7 months ago Vladislav F

    Ok, perfect..It’s working! I can’t understand why it didn’t work before…I did as you say upper.

  10. 8 years, 7 months ago Alex S
    Hi, I Work Here

    Hi Vladislav,

    You were telling it not to display the correct menu by adding the ! to the initial if statement. Is there anything else I can help you with today?

  11. 8 years, 7 months ago Vladislav F

    No, thx bro. <3 It's all alright for now

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More