Support Forum
Support › MB Settings Page › Field Group not showing in settingsResolved
add_filter( 'rwmb_meta_boxes', 'depts_short_code_page' );
function depts_short_code_page( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Shortcode Page Name', 'depts_short_code_page' ),
'id' => 'shortcode-page-name',
'settings_pages' => ['shortcode-page'],
'fields' => [
[
'name' => __( 'Shortcode Page Name', 'depts_short_code_page' ),
'id' => $prefix . 'depts_shortcode_page',
'type' => 'post',
'post_type' => ['page'],
'field_type' => 'select',
'required' => true,
'columns' => 4,
],
],
];
return $meta_boxes;
}
Hi Robert,
Can you please share the code that creates the settings page on your site?
add_filter( 'mb_settings_pages', 'short_code_page_settings' );
function short_code_page_settings( $settings_pages ) {
$settings_pages[] = [
'menu_title' => __( 'Settings', 'short_code_page_settings' ),
'option_name' => 'Shortcode Page',
'position' => 25,
'parent' => 'edit.php?post_type=department',
'style' => 'no-boxes',
'columns' => 1,
'icon_url' => 'dashicons-admin-generic',
];
return $settings_pages;
}
Hi Robert,
You need to add the parameter id
and use the parameter option_name
with the name in lowercase and underscore, with no space and special characters.
Please read more on the documentation https://docs.metabox.io/extensions/mb-settings-page/#using-code
Why is the ID not being added in the Meta Box AIO when generating the script(s)?
Not working;
//Shortcode Field Group
add_filter( 'rwmb_meta_boxes', 'depts_short_code_page' );
function depts_short_code_page( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Shortcode Page Name', 'depts_short_code_page' ),
'id' => 'shortcode-page-name',
'settings_pages' => ['shortcode-page'],
'fields' => [
[
'name' => __( 'Shortcode Page Name', 'depts_short_code_page' ),
'id' => $prefix . 'depts_shortcode_page',
'type' => 'post',
'post_type' => ['page'],
'field_type' => 'select',
'required' => true,
'columns' => 4,
],
],
];
return $meta_boxes;
}
//Shortcode Page Settings
add_filter( 'mb_settings_pages', 'short_code_page_settings' );
function short_code_page_settings( $settings_pages ) {
$settings_pages[] = [
'menu_title' => __( 'Settings', 'short_code_page_settings' ),
'id' => 'shortcode_page',
'option_name' => 'shortcode_page',
'position' => 25,
'parent' => 'edit.php?post_type=department',
'style' => 'no-boxes',
'columns' => 1,
'icon_url' => 'dashicons-admin-generic',
];
return $settings_pages;
}
Metabox code:
https://gist.github.com/robertlaneSUDO/b7cb662a31af0b5fab9251987b8dd644
I got it working! Thanks!