I've created a settings page and some custom fields for it, and I wanted to show this page under the Media menu as a submenu.
function add_my_settings_page( $settings_pages ) {
$settings_pages[] = [
'id' => 'my_settings_page',
'option_name' => 'my_settings_page',
'menu_title' => esc_html( 'My Settings Page' ),
'position' => 25,
'parent' => 'upload.php',
'capability' => 'upload_files',
'style' => 'no-boxes',
'columns' => 1,
'icon_url' => 'dashicons-admin-generic',
];
return $settings_pages;
}
add_filter( 'mb_settings_pages', 'add_my_settings_page' );
function add_my_settings_page_fields( $meta_boxes ) {
$meta_boxes[] = [
'title' => 'my_settings_page_fields',
'id' => 'my_settings_page_fields',
'settings_pages' => ['my_settings_page'],
'fields' => [
[
'name' => 'Upload Video',
'id' => 'upload_video',
'type' => 'file',
],
],
];
return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'add_my_settings_page_fields' );
I can see the submenu of that page, but when I access it, I only see the title of the settings page and the save button. All the other custom fields are not being loaded!
The strange thing is that when I change the parent to any other menu except upload.php
, or set it as a main menu, I'm then able to see the custom fields.