我正在尝试创建一个显示<li></li>
当用户登录时,不显示它。到目前为止我有这个,但它不起作用。有人知道如何正确地做到这一点吗?
add_filter(\'wp_nav_menu_items\',\'custom_nav_items\',1,2);
function custom_nav_items($menu, $args) {
global $bp;
$args = (array)$args;
if ( $args[\'theme_location\'] != \'primary\' )
return $menu;
$customNav = \'<li class="menu-item menu-item-type-post_type menu-item-object-page ss-nav-menu-item-5 ss-nav-menu-item-depth-0 ss-nav-menu-reg ss-nav-menu-mega-alignRight customNav"><a href="\'. $bp->loggedin_user->domain .\'">\'. $bp->loggedin_user->fullname .\'</a>
<ul class="sub-menu sub-menu-1">
<li class="menu-item menu-item-type-custom menu-item-object-custom ss-nav-menu-item-depth-1"><a href="\'. $bp->loggedin_user->domain .\'">View Profile</a></li>
<li class="menu-item menu-item-type-custom menu-item-object-custom ss-nav-menu-item-depth-1"><a href="\'. $bp->loggedin_user->domain .\'profile/edit/">Edit Profile</a></li>
<li class="menu-item menu-item-type-custom menu-item-object-custom ss-nav-menu-item-depth-1"><a href="\'. $bp->loggedin_user->domain .\'settings/">Edit Settings</a></li>\'
if ( is_user_logged_in() ) {
\'<li class="menu-item menu-item-type-custom menu-item-object-custom ss-nav-menu-item-depth-1"><a href="\'. wp_logout_url( bp_get_root_domain() ) .\'">Logout</a></li>\' }
\'<ul>
</li>\';
return $menu.$customNav;
}