Total newbie, I managed to get to the point where I have a separate menu item in the panel with some submenu pages (similar to elements such as settings, tools etc.)
This is the code I used:
add_action( 'admin_menu', 'register_my_custom_menu_page' );
function register_my_custom_menu_page() {
add_menu_page( 'custom menu title', 'Money Makers', 'manage_options', 'theme_options.php', '', plugins_url( 'myplugin/images/icon.png' ), 65 );
add_submenu_page( 'theme_options.php', 'Submenu 1', 'Submenu Page 1', 'manage_options', 'first-submenu-page', 'first_submenu_page_callback' );
add_submenu_page( 'theme_options.php', 'Submenu 2', 'Submenu Page 2', 'manage_options', 'second-submenu-page', 'second_submenu_page_callback' );
}
Now I would like to add some sections with fields to the first submenu page. I have this piece of code from some tutorial:
function eg_settings_api_init() {
// Add the section to reading settings so we can add our
// fields to it
add_settings_section(
'eg_setting_section',
'Example settings section in reading',
'eg_setting_section_callback_function',
'first-submenu-page'
);
// Add the field with the names and function to use for our new
// settings, put it in our new section
add_settings_field(
'eg_setting_name',
'Example setting Name',
'eg_setting_callback_function',
'first-submenu-page',
'eg_setting_section'
);
// Register our setting so that $_POST handling is done for us and
// our callback function just has to echo the <input>
register_setting( 'first-submenu-page', 'eg_setting_name' );
} // eg_settings_api_init()
add_action( 'admin_init', 'eg_settings_api_init' );
Where it says “first-submenu-page’ it used to be written ‘reading’ – and it was showing on the very bottom of the Reading submenu page. It worked with changing it to ‘writing’, but when I put ‘first-submenu-page’, the page (first submenu) remains empty.
Any idea what I’m doing wrong or what’s more to be done here?