WordPress : Nested Submenu in Admin

How can I have nested Nested Submenu in WordPress Admin Panel.

Like, In Plugins submenu, I want to have my plugin lets say ‘CC’ , Then I want to display its submenu letsay . ‘CC History’ , ‘CC About Me’

Read More

I dont have a clue, so any help would be appreciated
Thanks

Related posts

2 comments

  1. Try this

    /** Step 2 (from text above). */
    add_action( 'admin_menu', 'my_plugin_menu' );
    
    /** Step 1. */
    function my_plugin_menu() {
        add_options_page( 'My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options' );
    }
    
    /** Step 3. */
    function my_plugin_options() {
        if ( !current_user_can( 'manage_options' ) )  {
            wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
        }
        echo '<div class="wrap">';
        echo '<p>Here is where the form would go if I actually had options.</p>';
        echo '</div>';
    }
    
  2. Try this,
    
    This will create your plugin menu appear at the wordpress admin menu levels.
    
    //Call hook admin_menu to add plugin menu in WP admin section
    
    add_action('admin_menu', 'register_my_menu_page');
    
    //Main function to populate plugin menus
    
    function register_my_menu_page() {
    
        add_menu_page('Employee Register', 'Attendance', 'manage_options', 'at-main-menu', 'AtShowReport');
        add_submenu_page("at-main-menu", "Emp-timeoff-mast", "Report", 1, "at-main-menu", "fucntion_name");
        add_submenu_page("at-main-menu", "Manage Employees", "Manage Employees", 1, "manage-emp", "fucntion_name");
        add_submenu_page("at-main-menu", "Register Employee off time", "Register Time off", 1, "emp-reg-off-time", "fucntion_name");
        add_submenu_page("at-main-menu", "Employee status", "Status", 1, "emp-status", "fucntion_name");
        add_submenu_page("at-main-menu", "Holidays", "Holidays", 1, "emp-holiday", "fucntion_name");
    }
    
    function_name is the name of the fucntion that get executed when the menu is clicked
    
    Refer following link to get better understanding of these functions.
    https://codex.wordpress.org/Plugin_API/Action_Reference/admin_menu
    https://codex.wordpress.org/Function_Reference/add_menu_page
    https://codex.wordpress.org/Function_Reference/add_submenu_page
    

Comments are closed.