This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Hide menu on mobile; Vantage

Resolved 11 replies developerthemetheme-vantage
9 years ago · Last reply by Vladislav F 9 years ago

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.

Need fast email support? Get SiteOrigin Premium

Replies

11
  1. Alex S Staff 9 years, 11 months ago

    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. Vlad Skull 9 years, 11 months ago

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

  3. Alex S Staff 9 years, 11 months ago

    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.

    <?php
    if( ! wp_is_mobile() ){
        	get_template_part( 'parts/menu', apply_filters( 'vantage_menu_type', siteorigin_setting( 'layout_menu' ) ) );
    }
    ?>
  4. Vladislav F 9 years, 11 months ago

    Thx Man <3 As I want.

  5. Vladislav F 9 years, 11 months ago

    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. Alex S Staff 9 years, 11 months ago

    Hi Vladislav,

    Could you elaborate on the trouble you’re experiencing?

  7. Vladislav F 9 years, 11 months ago

    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. Alex S Staff 9 years, 11 months ago

    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. Vladislav F 9 years, 11 months ago

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

  10. Alex S Staff 9 years, 11 months ago

    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. Vladislav F 9 years, 11 months ago

    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.

Have a different question or issue?

Start New Thread