Metaboxes not visible on Settings page

Support MB Settings Page Metaboxes not visible on Settings page

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #10767
    austindwaustindw
    Participant

    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?

    #10773
    Anh TranAnh Tran
    Keymaster

    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.

    #10777
    austindwaustindw
    Participant

    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?

    #10780
    Anh TranAnh Tran
    Keymaster

    I'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.

    #10784
    austindwaustindw
    Participant

    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 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?

    #10787
    Anh TranAnh Tran
    Keymaster

    I got it. Did you select settings page in the Settings tab of the Builder, like this?

    https://i.imgur.com/xWjA7rV.png

    #10788
    austindwaustindw
    Participant

    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.

    #10789
    Anh TranAnh Tran
    Keymaster

    Can you send me the code that registers settings pages? Is it wrapped inside any hook (like 'init')?

    #10790
    austindwaustindw
    Participant

    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;
    }
    #10791
    austindwaustindw
    Participant

    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;
    }
    
    #10797
    Anh TranAnh Tran
    Keymaster

    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?

    #10805
    austindwaustindw
    Participant

    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

    #10809
    Anh TranAnh Tran
    Keymaster

    Thanks a lot for your info. I've found the bug and updated the extension. Please update it to the latest version.

    #10810
    austindwaustindw
    Participant

    Thank you!

    #10813
    austindwaustindw
    Participant

    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?

Viewing 15 posts - 1 through 15 (of 19 total)
  • The topic ‘Metaboxes not visible on Settings page’ is closed to new replies.