Tab custom fields don't appear when using the code
Support › MB Settings Page › Tab custom fields don't appear when using the codeResolved
- This topic has 2 replies, 2 voices, and was last updated 3 years ago by
Alaan TV.
-
AuthorPosts
-
April 18, 2022 at 6:31 AM #35690
Alaan TV
ParticipantI've created a new settings page that has 2 tabs, then created a new custom fields group and linked it to the first tab on the settings page. The settings page was working properly until this point.
Then I generated the PHP code for both, the settings page and the custom fields and trashed them.
I put the generated code in a file and included it in the
functions.php
file. I can see the settings page and its tabs, but no fields are showing on the settings tab.Here's the generated code, please advise if there's anything wrong with my code, and how to resolve the issue:
<?php add_filter( 'mb_settings_pages', 'register_settings__admins' ); function register_settings__admins( $settings_pages ) { $settings_pages[] = [ 'menu_title' => 'Admins Settings', 'option_name' => 'settings_admins', 'position' => 25, 'parent' => 'options-general.php', 'style' => 'no-boxes', 'columns' => 1, 'tabs' => [ 'settings_admins__general_tab' => 'General', 'settings_admins__sticky_posts_tab' => 'Sticky Posts', ], 'tab_style' => 'left', 'icon_url' => 'dashicons-admin-generic', ]; return $settings_pages; } add_filter( 'rwmb_meta_boxes', 'settings_admins_general_fields' ); function settings_admins_general_fields( $meta_boxes ) { $prefix = 'settings_'; $meta_boxes[] = [ 'title' => 'settings_admins__general', 'id' => 'settings_admins__general', 'settings_pages' => ['settings_admins'], 'tab' => 'settings_admins__general_tab', 'fields' => [ [ 'name' => 'Classic Editor', 'id' => $prefix . 'classic_editor_is_active', 'type' => 'checkbox', 'desc' => 'Use the classic editor instead of the block editor.', ], [ 'name' => 'Classic Widgets', 'id' => $prefix . 'classic_widgets_is_active', 'type' => 'checkbox', 'desc' => 'Use the classic view of widgets.', ], ], ]; return $meta_boxes; }
April 18, 2022 at 10:57 PM #35702Long Nguyen
ModeratorHi,
The generated code is missing the ID of the settings page that is required when creating a settings page. I've escalated this issue to the development team to fix it in the next update.
add_filter( 'mb_settings_pages', 'register_settings__admins' ); function register_settings__admins( $settings_pages ) { $settings_pages[] = [ 'menu_title' => 'Admins Settings', 'option_name' => 'settings_admins', 'id' => 'settings-admins', //here ... ]; return $settings_pages; }
Read more on the documentation https://docs.metabox.io/extensions/mb-settings-page/#using-code
April 19, 2022 at 8:29 AM #35709Alaan TV
ParticipantThank you! I added that line manually and it worked!
-
AuthorPosts
- You must be logged in to reply to this topic.