How To Show Or Hide Different Divi Menu Items On Each Device Tutorial By Pee Aye Creative

How To Show Or Hide Different Divi Menu Items On Each Device

Nelson Miller Pee Aye Creative
In this tutorial I will show you how to show or hide different WordPress menu navigation items per device in Divi.
Control Divi column stacking order on mobile

Join the Divi crowd!

Enable CSS Classes In WordPress Navigation Menu Items

The first step is to go to Appearance>Menus from your WordPress Dashboard. Select the menu that you want to edit.

Enable CSS Classes In Screen Options

The key thing here is to make sure CSS Classes is enabled in the Screen Options. At the top of the page, look for the “Screen Options” button, and this opens up some additional options. Find the “CSS Classes” checkbox and select it. Now, inside each menu item will be an additional field for you to add CSS classes. You’ll see what I mean in the screenshots in the next few steps.

Divi menu CSS classes screen options

Add CSS Classes To The WordPress Navigation Menu Items

Now that you have the CSS classes input field enabled, you can add a classes which we will target to hide the menu item. The CSS class is associated with the menu item. So if we target that class, we are targeting that specific menu item.

By default, a WordPress menu item will display on devices. But in Divi, we have three responsive options – Desktop, Tablet, and Phone. These are based on media queries, which we talk about in another tutorial. So what if you want to show or hide some menu items on different devices sizes?

We start with a CSS class. For the sake of this tutorial, we will keep it simple and use three classes, each will hide the menu item on a specific device size.

pa-menu-hide-desktop

pa-menu-hide-tablet

pa-menu-hide-phone

Just copy and past these classes according to which menu items you want to hide per device. You can watch the video to see this in action. Below is a screenshot to help explain this.

show or hide menu items in Divi

Add CSS Snippets To Show Or Hide Navigation Menu Items

Below you will find three CSS snippets, one for each device size in Divi. You can copy and paste them as needed. Just keep in mind that the class needs to be the same as the ones used in the menu item.

If you are using our free Divi child theme, place this snippet into the style.css file. Otherwise, place this in your Divi>Theme Options>Custom CSS code box. If you need help, check out our complete guide on Where To Add Custom Code In Divi.

Hide Menu Items On Desktop Device Sizes

/*hide menu items on Desktop device sizes*/

@media all and (min-width: 981px) {
	.pa-menu-hide-desktop {
		display: none;
	}
}

Hide Menu Items On Tablet Device Sizes

/*hide menu items on Tablet device sizes*/

@media all and (min-width: 768px) and (max-width: 980px) {
	.pa-menu-hide-tablet {
		display: none;
	}
}

Hide Menu Items On Desktop Device Sizes

/*hide menu items on Phone device sizes*/

@media all and (max-width: 768px) {
	.pa-menu-hide-phone {
		display: none;
	}
}

You can combine these snippets as needed. Just use whichever snippet you need that targets the class in the menu item. Now, when you view your menu, the items will show or hide according to the designated screen size.

Do It With A Setting!

Make life easier and use the Divi Responsive Helper instead, the ultimate Divi responsive toolkit with awesome features and settings to help make your website look and work great on all devices!

Divi Responsive Helper by Pee Aye Creative 2.3

Below is a screenshot of the responsive settings our plugin adds to the WordPress Menu items. As you can see, the checkmarks make it super easy to show or hide items on any device.

show or hide menu items per device with Divi Responsive Helper

Last updated Nov 16, 2021 @ 2:21 am

Subscribe

Each month we send out a roundup email newsletter with the latest tutorials, product updates, helpful resources, and any other industry or personal news. Occasionally we send an extra separate email here and there if we just can’t wait! So that’s what you will get if you subscribe, and you can always unsubscribe at any time if you just can’t take it anymore :)

Blog Post Optin

Please share this post!

Nelson Lee Miller (aka The Divi Teacher)

Nelson is the owner of Pee-Aye Creative in the beautiful state of Pennsylvania. He loves helping small businesses, exploring outdoors, building websites with Divi, and teaching others.
Pee Aye Creative Black Friday Sale

Our Once A Year Sale Is Happening Now!!!

25% OFF all Divi Plugins, Courses, and Child Themes!

Shop The Sale Now!

Asset 7

Shop Our Divi Products

Plugins • Courses • Templates

Visit The Shop

Pee Aye Creative Black Friday Sale

Our Once A Year Sale Is Happening Now!!!

25% OFF all Divi Plugins, Courses, and Child Themes!

Shop The Sale Now!

Divi Tutorials On YouTube

Our videos have views! Join subscribers and enjoy over video tutorials!

Visit Our Channel

Leave A Response!

By commenting you agree to our Blog & YouTube Comments Policy

4 Comments

  1. Brian Pearl

    Hi there…I know it’s been a couple of years, but this should still work? I’m trying it now and not having any luck hiding a menu item on desktop. Any tips?

    Reply
  2. John Sharkey

    Hi Nelson

    I’m looking to do something similar but slightly different. On the mobile menu (hamburger) version, I have a menu item set to non-clickable using a “#” in the URL, which is desired. The issue is in mobile since there is no mouse pointer, the non-clickable item appears “tappable” and when selected closes the menu. The desired action would be for it NOT to close the hamburger menu. Any way to do this? I would think removing the HREF for this would do it, but can’t figure out how! Thanks, John

    Reply
    • Hemant Gaba

      Hi John!

      Please add the class pa-menu-hide-mobile to the menu item and then add the following code:

      @media all and (max-width: 767px){
      .pa-menu-hide-mobile a{
      pointer-events: none;}
      }

      Let me know if it helps!

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Recent Posts

0

Your Cart