您可以这样做:
<?php
if ( is_user_logged_in() ) {
wp_nav_menu( array( \'theme_location\' => \'logged-in-menu\' ) );
} else {
wp_nav_menu( array( \'theme_location\' => \'logged-out-menu\' ) );
}
?>
EDIT:
这是另一种尝试,相同的理论,但不同的执行:
if ( is_user_logged_in() )
{
// Filter wp_nav_menu() to add additional links and other output
function new_nav_menu_items($items)
{
$homelink = \'<li class="home"><a href="\' . bp_loggedin_user_domain() . \'">\' . __(\'Profile\') . \'</a></li>\';
$items = $homelink . $items;
return $items;
}
add_filter( \'wp_nav_menu_items\', \'new_nav_menu_items\' );
}