Support Forum
Support › MB Settings Page › Metaboxes not visible on Settings page
I'm new to Meta Box and am not 100% clear on using the custom fields and meta boxes created with the plugin on a settings page. I am able to create a page (which I believe I have to do with code directly in a plugin or functions.php file) and have created a set of custom fields in a meta box. I am able to "assign" that set of fields to the settings page, but when I go to the page, there are no boxes. What am I missing?
Hi,
The settings page must be created using the method the plugin provides. The settings pages that created using normal Settings API are not supported. Because we can't hook into those settings page and show custom fields there.
Please follow this instruction to create settings pages. It's very similar to Settings API.
I followed the instructions to create the page but my understanding, from that page and what you're saying, is that I cannot create metaboxes and apply to that page, like I would a regular site page, but that I'd have to generate the fields and metaboxes code and put it within the functions.php or the plugin file. Is that correct?
I'm confused about "regular site page". The plugins allows you to:
Both the steps requires you to put code within functions.php or plugin file. If you use Meta Box Builder, then the Builder can help you do the 2nd step without copy and paste the code into functions.php file.
Well, I mean adding custom fields to a specific page, post, or template, that can be filled out. I've tried creating a settings page as part of functions.php and a plugin file. The pages are created with that code, but when I cannot get the custom fields to appear even when building them within the Meta Box Builder.
My understanding (and hope) was that I could create the fields with the builder, apply them to the settings page, and those fields show on that setting page when I go there. That's not what happens – the page is there but the meta boxes/custom fields are not. Hence my confusion.
Is that what I should expect to happen? Without adding the fields codes to the plugin or functions.php?
I got it. Did you select settings page in the Settings tab of the Builder, like this?
I did, and it still didn't show up there. I also checked the generated code for the fields and instead of showing the settings page ID, is showed an empty array.
Can you send me the code that registers settings pages? Is it wrapped inside any hook (like 'init')?
This is what I see...
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array (
'title' => 'Test Settings Fields',
'id' => 'test-settings-fields',
'fields' => array(
array (
'id' => 'text_1',
'type' => 'text',
'name' => 'Text Field',
),
),
'settings_pages' => array(
),
);
return $meta_boxes;
}
Oh, and this is what I have for the settings page itself:
add_filter( 'mb_settings_pages', 'prefix_options_page' );
function prefix_options_page( $settings_pages ) {
$settings_pages[] = array(
'id' => 'author-phase-two',
'option_name' => 'author_phase_two',
'menu_title' => 'Site Settings',
'page_title' => 'Custom Site Settings',
'position' => 1,
'capability' => 'edit_pages'
//'style' => 'no-boxes',
);
return $settings_pages;
}
Hi, I've just added your code of the settings page to my localhost and it shows in the Builder. Here is the screenshot:
https://i.imgur.com/KKuYpfL.png
Perhaps there's something else?
Yep, I see that, too, and I save the meta box with that set, but the fields still don't show on the settings page, which is where my confusion lies.
Meta Box Fields:
https://phasetwo.austindesignworks.com/wp-content/uploads/2018/07/Screen-Shot-2018-07-31-at-1.41.26-PM.png
Settings Page: https://phasetwo.austindesignworks.com/wp-content/uploads/2018/07/Screen-Shot-2018-07-31-at-1.39.15-PM.png
Thanks a lot for your info. I've found the bug and updated the extension. Please update it to the latest version.
Thank you!
I ran the update from the WordPress updates for Meta Box AIO, but the change didn't make a difference. Do I need to change the code for the settings page?