在动态wordpress菜单中添加类到下拉菜单 [英] add class to dropdown menu inside dynamic wordpress menu
问题描述
我对WordPress很新,并且无法创建该网站的主导航。
I am pretty new to wordpress and am having trouble creating the primary navigation for the site.
我使用wp-nav-menu输出我的动态菜单。
I am using wp-nav-menu to output my dynamic menu.
我想输出的代码如下...
The code I would like to output is the following...
<ul class="mainNav">
<li><a href="">Home</a></li>
<li class="dropdown">
<a href="">Treatments<span></span></a>
<ul>
<li><a href="">Body Treatments</a></li>
<li><a href="">Make Up</a></li>
<li><a href="">Skincare</a></li>
</ul>
</li>
<li><a href="">Latest News</a></li>
<li><a href="">Aftercare</a></li>
<li><a href="">Contact</a></li>
</ul>
我以前用来获取菜单的代码是... ...
The code I have used to get the menu above is this...
<?php wp_nav_menu(
array(
'menu' => 'Primary Navigation',
'items_wrap' => '<ul class="mainNav">%3$s</ul>'
)
); ?>
这让我得到主菜单,但我不知道如何获得 < li>
与下拉列表类别。我也想在其中一个链接中放置一个< span>
,如您在HTML代码中所看到的那样。
This gets me the main menu but I do not know how to get the <li>
with the class of dropdown. I would also like to place a <span>
inside one of the links, as you can see in my HTML code.
任何帮助将不胜感激!
推荐答案
我已经弄清楚了,会写在这里,万一有人有同样的问题。
I have figured it out and will write it here in case anyone has the same problem.
在wordpress管理员中,有一个称为屏幕选项的链接。打开这个,并勾选CSS类,然后可以将各个类添加到菜单项。
In the wordpress admin, there is a link called screen options. Open this, and tick CSS classes, you can then add individual classes to menu items.
这篇关于在动态wordpress菜单中添加类到下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!