add_menu_page example
Example 1: wordpress add submenu
add_menu_page('My Custom Page', 'My Custom Page', 'manage_options', 'my-top-level-slug');
add_submenu_page( 'my-top-level-slug', 'My Custom Page', 'My Custom Page',
'manage_options', 'my-top-level-slug');
add_submenu_page( 'my-top-level-slug', 'My Custom Submenu Page', 'My Custom Submenu Page',
'manage_options', 'my-secondary-slug');
Example 2: how add administration menu in wordpress
<?php
add_action( 'admin_menu', 'my_menu' );
function my_menu() {
add_options_page(
'My Options',
'My Menu',
'manage_options',
'my-unique-identifier',
'my_options'
);
}
function my_options() {
if ( !current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo 'Here is where I output the HTML for my screen.';
echo '</div><pre>';
}
?>