晚上好,我需要将以下静态菜单转换为 WordPress 的菜单。下面是 HTML 代码:
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container px-5">
<a class="navbar-brand" href="index.html">Start Bootstrap</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item"><a class="nav-link" href="index.html">Home</a></li>
<li class="nav-item"><a class="nav-link" href="about.html">About</a></li>
<li class="nav-item"><a class="nav-link" href="contact.html">Contact</a></li>
<li class="nav-item"><a class="nav-link" href="pricing.html">Pricing</a></li>
<li class="nav-item"><a class="nav-link" href="faq.html">FAQ</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownBlog" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Blog</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownBlog">
<li><a class="dropdown-item" href="blog-home.html">Blog Home</a></li>
<li><a class="dropdown-item" href="blog-post.html">Blog Post</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownPortfolio" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Portfolio</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownPortfolio">
<li><a class="dropdown-item" href="portfolio-overview.html">Portfolio Overview</a></li>
<li><a class="dropdown-item" href="portfolio-item.html">Portfolio Item</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
在主题 header.php 文件中的 PHP 代码下方:
<?php
wp_nav_menu(array(
'theme_location' => 'menu-1',
'container_id' => 'site-navigation',
'menu_class' => 'navbar-nav ms-auto mb-2 mb-lg-0',
'menu_id' => 'primary-menu',
'add_a_class' => 'nav-link',
'add_li_class' => 'nav-item',
));
?>
一切正常,但没有添加“nav-link”和“nav-item”类。我该如何解决?谢谢