Show some menu sub items as dropdown under a menu item
Remove the first closing </li> and wrap the sub-items inside <ul></ul>, then close the parent <li>. For Example: function my_custom_menu_item($items, $args) { if(is_user_logged_in() && $args->theme_location == ‘primary’) { $user=wp_get_current_user(); $name=$user->display_name; $items .= ‘<li><a href=””>’.$name.'</a>’; $items .= ‘<ul>’; $items .= ‘<li><a href=”http://wordpress.stackexchange.com/my-profile”>My Profile</a></li>’; $items .= ‘<li><a href=”http://wordpress.stackexchange.com/my-posts”>My Posts</a></li>’; $items .= ‘<ul>’; $items .= ‘</li>’; } return … Read more