• I added some hard coded menu items for login & logout and profile, now i want to add a sub menu to profile menu item.
    This is the code i have:

    add_filter('wp_nav_menu_items', 'add_register_link', 10, 2);
    function add_register_link($items, $args) {
    
            ob_start();
            wp_register('');
            $registerlink = ob_get_contents();
            ob_end_clean();
            $items .= '<div class="menulogin">'. $registerlink .'</div>';
        return $items;
    }
    
    add_action( 'register' , 'register_replacement' );
    function register_replacement( $link ){
    	if ( ! is_user_logged_in() ) {
    		if ( get_option('users_can_register') )
    			$link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;
    		else
    			$link = '';
    	} else {
    		$link = $before . '<a href="' . admin_url() . '">' . __('My Account') . '</a>' . $after;
        }
    	return $link;
    }

    I want to add a sub menu to My Account menu item, how can I accomplish that?

    [ Please do not bump, that’s not permitted here. ]

  • The topic ‘Add sub menu to hard coded menu item’ is closed to new replies.