简体   繁体   English

自定义类在wp_nav_menu中不起作用。 请告诉我我的代码有什么问题?

[英]Custom class is not working in wp_nav_menu. Please tell me What's wrong in my code?

I have two file first is header.php. 我首先有两个文件是header.php。

I want to add custom class in my menu but it's not working. 我想在菜单中添加自定义类,但无法正常工作。 If you have any solution please tell me. 如果您有任何解决方案,请告诉我。 I am already before sometime. 我已经有时间了。 But now i am forgot. 但是现在我忘了。

$defaults = array(
'theme_location'  => 'header-menu',
'container_class' => 'top-menu-container',
'container_id'    => 'cssmenu',
'menu_class'      => 'menu',
'menu_id'         => 'menu-top-menu1',
);
echo wp_nav_menu( $defaults);

functions.php code is following functions.php代码如下

register_nav_menu('header-menu','Top Menu');

Your code is already working.. I guess you have done some other mistake as the parameter you have send and throwing the same 'menu class' 您的代码已经在工作。.我想您在发送参数时抛出了其他错误,并抛出了相同的“菜单类”

By the way you dont have to echo wp_nav_menu() function.. 顺便说一下,您不必回显wp_nav_menu()函数。

Furthur More: https://developer.wordpress.org/reference/functions/wp_nav_menu/ 更多信息: https : //developer.wordpress.org/reference/functions/wp_nav_menu/

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

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