php – How make all generations of children elements from wp_nav_menu() into siblings

Question

I’m using wp_nav_menu() to load a custom menu with many layers of nested submenus:

Grandparent 1
  Parent 1.1
  Parent 1.2
    Child 1.2.1
    Child 1.2.2
  Parent 1.3
Grandparent 2
  Parent 2.1
  Parent 2.2
    Child 2.2.1
  Parent 2.3
    Child 2.3.1
Grandparent 3
  Parent 3.1
    Child 3.1.1
      Childest 3.1.1.1

I’d like to call this menu using wp_nav_menu() in such a way that all the elements are returned as sibling <li> elements in a single <ul> element.

<ul>
  <li>Grandparent 1
  <li>Parent 1.1
  <li>Parent 1.2
  <li>Child 1.2.1

etc...

Is this possible?

Thanks,

0
willbeing 1 year 2022-02-22T22:41:11-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse