xxxxxxxxxx
<?php
// Add a menu item to the WordPress admin menu
function custom_admin_menu() {
add_menu_page(
__( 'Aanbod', 'textdomain' ), // Menu title
__( 'Aanbod', 'textdomain' ), // Page title
'manage_options', // Capability
'aanbod', // Menu slug
'aanbod_page_content', // Callback function
'dashicons-admin-page', // Icon
5 // Position
);
// Add submenu header
add_submenu_page(
'admin.php', // Parent slug
'', // Page title (empty)
'', // Menu title (empty)
'manage_options', // Capability
'aanbod', // Menu slug
'' // Callback function (empty)
);
// Add All Aanbod submenu item
add_submenu_page(
'aanbod', // Parent slug
__( 'All Aanbod', 'textdomain' ), // Page title
__( 'All Aanbod', 'textdomain' ), // Menu title
'manage_options', // Capability
'aanbod', // Menu slug
'all_aanbod_page_content' // Callback function
);
// Add other submenus
add_submenu_page(
'aanbod', // Parent slug
__( 'Subitem 1', 'textdomain' ), // Page title
__( 'Subitem 1', 'textdomain' ), // Menu title
'manage_options', // Capability
'subitem-1', // Menu slug
'subitem_1_page_content' // Callback function
);
add_submenu_page(
'aanbod', // Parent slug
__( 'Subitem 2', 'textdomain' ), // Page title
__( 'Subitem 2', 'textdomain' ), // Menu title
'manage_options', // Capability
'subitem-2', // Menu slug
'subitem_2_page_content' // Callback function
);
add_submenu_page(
'aanbod', // Parent slug
__( 'Subitem 3', 'textdomain' ), // Page title
__( 'Subitem 3', 'textdomain' ), // Menu title
'manage_options', // Capability
'subitem-3', // Menu slug
'subitem_3_page_content' // Callback function
);
}
// Callback function for the Aanbod page
function aanbod_page_content() {
// Add your page content here
}
// Callback function for the All Aanbod page
function all_aanbod_page_content() {
// Add your page content here
}
// Callback function for the Subitem 1 page
function subitem_1_page_content() {
// Add your page content here
}
// Callback function for the Subitem 2 page
function subitem_2_page_content() {
// Add your page content here
}
// Callback function for the Subitem 3 page
function subitem_3_page_content() {
// Add your page content here
}
// Hook into the admin menu
add_action( 'admin_menu', 'custom_admin_menu' );
?>
xxxxxxxxxx
function wpdocs_register_my_custom_submenu_page() {
add_submenu_page(
'edit.php',
'Profil',
'Profil',
'manage_options',
'my-custom-submenu-page',
'my_custom_submenu_page_callback',
);
}
add_action('admin_menu', 'wpdocs_register_my_custom_submenu_page');
xxxxxxxxxx
Slugs for $parent_slug (first parameter)
Dashboard: ‘index.php’
Posts: ‘edit.php’
Media: ‘upload.php’
Pages: ‘edit.php?post_type=page’
Comments: ‘edit-comments.php’
Custom Post Types: ‘edit.php?post_type=your_post_type’
Appearance: ‘themes.php’
Plugins: ‘plugins.php’
Users: ‘users.php’
Tools: ‘tools.php’
Settings: ‘options-general.php’
Network Settings: ‘settings.php’