简体   繁体   English

我可以将课程添加到 <li> 由WordPress输出的wp_nav_menu()函数?

[英]Can I add a class to the <li>'s output by WordPress' wp_nav_menu() function?

I'm using a grid layout, and all the links in my menu need the class grid_1 , but WordPress automatically generates the classes page_item page-item-# . 我使用的是网格布局,并且菜单中的所有链接都需要grid_1 ,但是WordPress自动生成class page_item page-item-# How can I add my class to the li? 如何将我的课程添加到li中? I'm aware that I could alternately add an entry under .page_item to my stylesheet, but I feel like that's more messy than it should be. 我知道我可以在.page_item下交替添加一个条目到我的样式表中,但是我觉得那比应该的更混乱。

Thanks in advance! 提前致谢!

There's not a way but you can add a custom class to the ul and use that to target your li's. 没有办法,但是您可以向ul添加自定义类,然后使用该类来定位您的li。

$args = array(
'menu_class' => 'myclass'
);

wp_nav_menu($args);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM