[英]Wordpress menus
im having a problem with menus. 我有菜单问题。 I had a template that wasnt originaly for WP.
我有一个模板,它并不是WP独有的。 so i integrated it.
所以我整合了它。
when i started the site there was only one menu which works great. 当我启动网站时,只有一个菜单很棒。 i added
<?php wp_nav_menu('primary'); ?>
我添加了
<?php wp_nav_menu('primary'); ?>
<?php wp_nav_menu('primary'); ?>
and its all ok <?php wp_nav_menu('primary'); ?>
一切都还好
Now i need to add another one (custom links in the header section) sooo i used this method 现在我需要添加另一个(标题部分中的自定义链接),所以我使用了这种方法
register_nav_menus( array(
'header' => 'Header menu',
'footer' => 'Footer menu'
) );
and recieved new locations for menus. 并获得了菜单的新位置。 for the second menu i added
对于我添加的第二个菜单
<?php wp_nav_menu( array( 'theme_location' => 'header', 'menu_class' => 'nav-menu', 'fallback_cb' => false ) ); ?>
now the problem: there is a primary menu (it has few items) and the custom menu ( its currently empty) 现在的问题是:有一个主菜单 (它只有很少的项目)和自定义菜单 (它目前是空的)
when i add new page to custom menu its being shown in both primary and custom menus. 当我将新页面添加到自定义菜单时,它同时显示在主菜单和自定义菜单中。
if i delete all the items from custom menu , primary menu items are back in place... 如果我从自定义菜单删除所有项目,则主菜单项目又恢复原位...
what is the problem? 问题是什么? Thank you.
谢谢。
If I understand correctly, it looks like you are pointing to the wrong registered menu in the wp_nav_menu()
. 如果我理解正确,则好像您指向
wp_nav_menu()
错误的注册菜单。 Specifically in the theme_location
. 特别是在
theme_location
。
When you are building the "second menu" which is the "footer", theme_location
should be footer
since that is the name you gave it in the register_nav_menus()
. 当构建“页脚”的“第二菜单”时,
theme_location
应该为footer
因为这是您在register_nav_menus()
为其指定的名称。
<?php wp_nav_menu(
array( 'theme_location' => 'footer', // Change 'header' to 'footer'
'menu_class' => 'nav-menu',
'fallback_cb' => false )
);
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.