所以我对整个WordPress很陌生,但我对HTML/CSS还是有经验的。我已经在WordPress的Admin区域创建了一个新菜单,但是当分配给主题时,它仍然没有正确显示。如果我在这里完全失明了,请提前道歉,但是PHP也不是我的强项。
下面是所讨论的代码,与标题部分中菜单所在的位置相关:
<div id="nav-primary" class="nav"><nav>
<?php if ( is_user_logged_in() ) {
wp_nav_menu( array( 'theme_location' => 'logged-in-menu' ) ); /* if the visitor is logged in, this primary navigation will be displayed */
} else {
wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); /* if the visitor is NOT logged in, this primary navigation will be displayed. if a single menu should be displayed for both conditions, set the same menues to be displayed under both conditions through the Wordpress backend */
} ?>
</nav></div><!--#nav-primary-->我知道“标题菜单”指向我设置的新菜单,但它没有显示正确的菜单。相反,它显示了大量的菜单项,而我设置的菜单项只有4项。
有人能为这件事提供一点线索吗?我真的很感谢你的帮助。
谢谢!
标记
发布于 2012-10-16 10:13:06
检查这一步。
告诉我你还需要什么帮助。
编辑新代码的登录和不登录使用菜单。
/* Add two custom menu */
function register_my_menus() {
register_nav_menus(
array( 'top-menu' => _( 'Top Menu' ),
'header-top-menu' => _( 'Header Top Menu' ) ) );
}
add_action( 'init', 'register_my_menus' );
<?php if ( is_user_logged_in() )
{ wp_nav_menu( array( 'theme_location' => 'top-menu' ) ); }
else { wp_nav_menu( array( 'theme_location' => 'header-top-menu' ) ); }
?>https://stackoverflow.com/questions/12911742
复制相似问题