• Resolved Jake Reimer

    (@jake-reimer)


    Is there a way I can hide the dropdown menu on the mobile view for users that are not logged in? If anyone could help me with an answer that would be awesome, thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can create 2 divs for the menu including the same menu

    for example u can create one div has calss “logged-users-div” including menu.
    and copy it with a class “not-logged-users-div” or any other classes for both

    then we can do the following >

    in your template page.

    <?php
    if ( is_user_logged_in() ) { ?>
    	<div class="logged-users-div">
    <ul>
    <li>element</li>
    <li>element</li>
    <li>element
    <ul class="submenu">
    <li>child element</li>
    <li>child element</li>
    <li>child element</li>
    <li>child element</li>
    </ul>
    </li>
    </ul>
    
    </div>
    
    <?php } else { ?>
    
    	<div class="not-logged-users-div">
    <ul>
    <li>element</li>
    <li>element</li>
    <li>element
    <ul class="submenu">
    <li>child element</li>
    <li>child element</li>
    <li>child element</li>
    <li>child element</li>
    </ul>
    </li>
    </ul>
    
    </div>
    
    <?php } ?>

    and in your css , you can do this

    .not-logged-users-div .submenu{
    display:none;
    }

    or in custom window width

    @media(max-width: 480px){
    .not-logged-users-div .submenu{
    display:none;
    }
    }

    Here’s another option:

    1. In your child theme create a new file like “my-styles.css”

    2. Add this css to that file:

    #nav-header .nav-toggle {
      display: none !important;
    }

    3. Add this function to your child theme functions.php file:

    add_action( 'wp_enqueue_scripts', 'enqueue_my_styles');
    function enqueue_my_styles() {
      if ( !is_user_logged_in() ) {
        wp_enqueue_style( 'my-style', get_stylesheet_directory_uri().'/my-styles.css' );
      }
    }
    Thread Starter Jake Reimer

    (@jake-reimer)

    I’m set with this now. Thank you guys!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide Dropdown menu’ is closed to new replies.