I got this code to insert menu bar in the PRIMARY menubar, but I can not find a way to insert it into my secondary, or top menubar above the primary menu bar. Could anyone teach me how to do that?
add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
function add_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'menu_top') {
$items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';
}
elseif (!is_user_logged_in() && $args->theme_location == 'menu_top') {
$items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
}
return $items;
}
=============Additional Info============== I am using Custom Community Theme 1.4. Just in case it will be helpful, and I tried to use 'menu_top' as keyword rather than primary, but it does not work, it originally was primary!
==============MORE INFO==================== Ok, in request, I found more info, but as I tried, menu_top does not work, and seem these code already tell what is the name of the menu, is that right?
// This theme uses wp_nav_menu() in one location.
register_nav_menus(array(
'menu_top' => __('Header top menu', 'cc'),
'primary' => __('Header bottom menu', 'cc'),
));