我有一个静态主菜单,但我想将类“active”添加到导航中的菜单项中,如果它是页面或该页面的子菜单项。
我想象它是一系列类似的东西:if($post->post\\u parent==“1”){add\\u class“active”}
这可以用Wordpress完成吗?
<a class="item" href="/index.php">
<i class="home icon"></i> Home
</a>
<a class="item" href="/about-us">
<i class="doctor icon"></i> About Us
</a>
<a class="item" href="/how-do-i">
<i class="help icon"></i> How Do I
</a>
<a class="item" href="/services">
<i class="info icon"></i> Our Services
</a>
<a class="item" href="/do-it-online">
<i class="user icon"></i> Do It Online
</a>
<a class="item" href="/contact-us">
<i class="mail icon"></i> Contact Us
</a>
</nav>