[Resolved] Can we display the menus conditionally?

Home Forums Support [Resolved] Can we display the menus conditionally?

Home Forums Support Can we display the menus conditionally?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #133418
    Pete

    How would we dig into the code to put a conditional thing around the menus?

    #133425
    Tom
    Lead Developer
    Lead Developer

    This plugin may be helpful: https://wordpress.org/plugins/if-menu/

    Never used it before, but it looks promising.

    #133458
    Pete

    Not the menu items, but the whole menu itself! Whooa!

    #133517
    Tom
    Lead Developer
    Lead Developer

    This one does the whole menu: https://wordpress.org/plugins/menu-swapper/

    #133523
    bdbrown

    Here’s a way to hide the main menu if the user isn’t logged on:

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

    2. Add this css to that file:

    nav.main-navigation {
      display: none;
    }
    

    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' );
      }
    }
    
    #169141
    Pete

    Thanks!

    #169183
    Tom
    Lead Developer
    Lead Developer

    No problem, glad I could help 🙂

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.