Custom Fields
Re-Envisioned
Support MB Settings Page Metaboxes not visible on Settings page

  • Creator
    Topic
  • #10767
    austindw
    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?

Viewing 10 replies - 1 through 10 (of 18 total)
  • Author
    Replies
  • #10773
    Anh 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
    austindw
    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 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 Meta Box Builder, then the Builder can help you do the 2nd step without copy and paste the code into functions.php file.

    #10784
    austindw
    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 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?

    #10787
    Anh Tran
    Keymaster

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

    View post on imgur.com

    #10788
    austindw
    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 Tran
    Keymaster

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

    #10790
    austindw
    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
    austindw
    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 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:

    View post on imgur.com

    Perhaps there’s something else?

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