如何创建如本例所示的菜单?

时间:2017-02-04 作者:Anton Essential

我尝试用下面的结构创建菜单循环,但我做不到,默认函数wp\\u nav\\u menu不允许这样做,我不明白hot怎么做。我需要类似于示例中的数据remodal target count和data-remodaul-id的结构?

            <nav class="main-menu">
              <ul class="row between">
                <li class="main-menu__item">
                  <a class="main-menu__link" href="#" data-remodal-target="modal00">News</a>
                  <div class="modal main-menu__modal-wrapper" data-remodal-id="modal00">
                    <button class="button_close" data-remodal-action="close"></button>
                    <div class="modal-wrapper">
                      <div class="modal__content">
                        <ul class="main-menu__sub-menu animated fadeIn">
                          <li class="main-menu__sub-menu__item">
                            <a class="main-menu__sub-menu__link" href="page1.html">page 1</a>
                          </li>
                          <li class="main-menu__sub-menu__item">
                            <a class="main-menu__sub-menu__link" href="page2.html">page 2</a>
                          </li>
                        </ul>
                      </div>
                    </div>
                  </div>
                </li>
                <li class="main-menu__item">
                  <a class="main-menu__link" href="#" data-remodal-target="modal01">Media</a>
                  <div class="modal main-menu__modal-wrapper" data-remodal-id="modal01">
                    <button class="button_close" data-remodal-action="close"></button>
                    <div class="modal-wrapper">
                      <div class="modal__content">
                        <ul class="main-menu__sub-menu animated fadeIn">
                          <li class="main-menu__sub-menu__item">
                            <a class="main-menu__sub-menu__link" href="page1.html">page 1</a>
                          </li>
                          <li class="main-menu__sub-menu__item">
                            <a class="main-menu__sub-menu__link" href="page2.html">page 2</a>
                          </li>
                        </ul>
                      </div>
                    </div>
                  </div>
                </li>
                <li class="main-menu__item">
                  <a class="main-menu__link" href="#" data-remodal-target="modal02">Serv</a>
                  <div class="modal main-menu__modal-wrapper" data-remodal-id="modal02">
                    <button class="button_close" data-remodal-action="close"></button>
                    <div class="modal-wrapper">
                      <div class="modal__content">
                        <ul class="main-menu__sub-menu animated fadeIn">
                          <li class="main-menu__sub-menu__item">
                            <a class="main-menu__sub-menu__link" href="page1.html">page 1</a>
                          </li>
                          <li class="main-menu__sub-menu__item">
                            <a class="main-menu__sub-menu__link" href="page2.html">page 2</a>
                          </li>
                        </ul>
                      </div>
                    </div>
                  </div>
                </li>
              </ul>
            </nav>

1 个回复
最合适的回答,由SO网友:Anwer AR 整理而成

您必须扩展Walker_Nav_Menu 使用您自己的类进行修改WP Nan Menus.

最好的例子之一是wp_bootstrap_navwalker. 您还可以扩展walker类以构建自定义导航结构。

相关推荐

Add extra markup to WP menus

我被要求将一个HTML网站重新开发为一个WP主题,它有一个非常高级的菜单结构,我不太确定如何复制它。第二个菜单项有一个子菜单,但它不仅仅是“li”中的“ul”,还有额外的div等。。因为下拉列表有3列布局,其中2列包含子链接,第3列包含内容。这是一个示例:<ul class=\"nav navbar-nav three\"> <li class=\"dropdown yamm-fw\"> <a href=\"#\" class=\"dropdown-toggl