个性化阅读
专注于IT技术分析

我如何在wp_nav_menus中使用li和一个类?

我如何在wp_nav_menus中使用<li>和<a>类?

<div class="collapse navbar-collapse" id="ftco-nav">
    <ul class="navbar-nav nav ml-auto">
        <li class="nav-item"><a href="#home-section" class="nav-link"><span>Home</span></a></li>
        <li class="nav-item"><a href="#about-section" class="nav-link"><span>About</span></a></li>
        <li class="nav-item"><a href="#skills-section" class="nav-link"><span>Skills</span></a></li>
        <li class="nav-item"><a href="#projects-section" class="nav-link"><span>Projects</span></a></li>
        <li class="nav-item"><a href="#blog-section" class="nav-link"><span>My Blog</span></a></li>
        <li class="nav-item"><a href="#contact-section" class="nav-link"><span>Contact</span></a></li>
    </ul>
</div>

#1


    <ul class="list-unstyled nav1 cl-effect-10">
        <li class="Home"><a  data-hover="Home" class="active"><span>Home</span></a></li>
        <li class="About"><a data-hover="About"  href="about.html"><span>About</span></a></li>
        <li class="Rooms"><a data-hover="Rooms"  href="rooms.html"><span>Rooms</span></a></li>
        <li class="Gallery"><a data-hover="Gallery"  href="gallery.html"><span>Gallery</span></a></li>
        <li class="Dinning"><a data-hover="Dinning" href="dinning.html"><span>Dinning</span></a></li>
        <li class="News"><a data-hover="News" href="news.html"><span>News</span></a></li>
        <li><a data-hover="Contact Us" href="contact.html"><span>contact Us</span></a></li>
    </ul>
  </div>

请尝试以下代码:

   <?php
     $location=get_nav_menu_locations();
     $menuid =$location['header'];
     $primarymenu = wp_get_nav_menu_items($menuid);
   ?>
 <ul class="list-unstyled nav1 cl-effect-10 ">
      <?php
        foreach($primarymenu as $key=>$value)
        {
      ?>
        <li class="<?php echo $value->title; ?>"><a data-hover="<?php echo $value->title;?>"  href="<?php echo $value->url; ?>"><span><?php echo $value->title; ?></span></a></li>
      <?php   
        }
      ?>
 </ul>
</div>
赞(0)
未经允许不得转载:srcmini » 我如何在wp_nav_menus中使用li和一个类?

评论 抢沙发

评论前必须登录!