Could we help you? Please click the banners. We are young and desperately need the money
WordPress offers functions for registering your own custom backend pages as well as sub-pages. Here's how to do it.
Whether you want to create a top-level admin page or a sub-page, you must set up a render function that handles generating the HTML structure for the page.
Example:
<?php
function render_test_page() {
?>
<div class="wrap">
<h1>
Test Admin Page
</h1>
<p>
Hello World
</p>
</div>
<?php
}
?>
Now comes the time to register your new page.
For a top-level admin page, use the add_menu_page() function:
<?php
function add_test_page() {
add_menu_page(
'Page Title',
'Menu Title',
'manage_options', // capability
'test-page', // slug
'render_test_page' // render function
);
}
add_action('admin_menu', 'add_test_page');
?>
For a sub-page, use the aptly named add_submenu_page() function:
<?php
function add_test_sub_page() {
add_submenu_page(
'test-page', // parent slug
'Page Title',
'Menu Title',
'manage_options', // capability
'test-sub-page', // slug
'render_test_page' // render function
);
}
add_action('admin_menu', 'add_test_sub_page', 100);
?>
Notice the priority when registering the sub-page. It's crucial that the action is executed after the parent page is registered.