Dropdown menu items created regardless of subitems being present in the menu structure

I generated a menu with the use of the Piengrow WordPress menu action. It has a few dropdowns and for these dropdowns I created a placeholder element that the action correctly identifies as the dropdown template. However, if there are no subitems present in the menu structure beneath a main title, it still generates the template, only here with the placeholder values (which do not link to anywhere as these href attributes are empty.) How can I make it so that the action leaves out the dropdown element when there are no sub items present?

You must have 2 <li>, different in your menu structure:

  • one structured as a dropdown menu and another as a simple menu.

In your structure, I see that all <li> contain a <ul> that acts as a submenu.

You should create another, simpler <li><a href="#">Simple menu item</a></li>, which does not contain an ul.submenu.

By doing this, when you use the wordpress “Menu” action and assign the “Menu item with dropdown” option to your dropdown menu, Pinegrow will recognize the other remaining <li> as an item without a dropdown.

That's your menu structure:

How it should be

3 Likes