Metaboxes not visible on Settings page
Support › MB Settings Page › Metaboxes not visible on Settings page
- This topic has 18 replies, 2 voices, and was last updated 6 years, 9 months ago by
austindw.
-
AuthorPosts
-
July 29, 2018 at 12:31 PM #10767
austindw
ParticipantI'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?
July 30, 2018 at 5:53 PM #10773Anh Tran
KeymasterHi,
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.
July 31, 2018 at 12:18 AM #10777austindw
ParticipantI 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?
July 31, 2018 at 8:24 AM #10780Anh Tran
KeymasterI'm confused about "regular site page". The plugins allows you to:
- Create a settings page
- Create meta boxes and fields for that settings page
Both the steps requires you to put code within functions.php or plugin file. If you use MB Builder, then the Builder can help you do the 2nd step without copy and paste the code into functions.php file.
July 31, 2018 at 10:31 AM #10784austindw
ParticipantWell, 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 MB 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?
July 31, 2018 at 1:37 PM #10787Anh Tran
KeymasterI got it. Did you select settings page in the Settings tab of the Builder, like this?
July 31, 2018 at 1:40 PM #10788austindw
ParticipantI 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.
July 31, 2018 at 1:42 PM #10789Anh Tran
KeymasterCan you send me the code that registers settings pages? Is it wrapped inside any hook (like 'init')?
July 31, 2018 at 1:48 PM #10790austindw
ParticipantThis 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; }
July 31, 2018 at 2:13 PM #10791austindw
ParticipantOh, 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; }
July 31, 2018 at 5:33 PM #10797Anh Tran
KeymasterHi, 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?
August 1, 2018 at 1:42 AM #10805austindw
ParticipantYep, 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.pngSettings Page: https://phasetwo.austindesignworks.com/wp-content/uploads/2018/07/Screen-Shot-2018-07-31-at-1.39.15-PM.png
August 1, 2018 at 8:17 AM #10809Anh Tran
KeymasterThanks a lot for your info. I've found the bug and updated the extension. Please update it to the latest version.
August 1, 2018 at 8:25 AM #10810austindw
ParticipantThank you!
August 1, 2018 at 8:36 AM #10813austindw
ParticipantI 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?
-
AuthorPosts
- The topic ‘Metaboxes not visible on Settings page’ is closed to new replies.