开发者

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

开发者 https://www.devze.com 2023-01-29 02:37 出处:网络
I\'m开发者_C百科 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-#. How can I add my class to the li? I\'

I'm开发者_C百科 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-#. How can I add my class to the 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.

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.

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

wp_nav_menu($args);
0

精彩评论

暂无评论...
验证码 换一张
取 消