Custom Fields
Re-Envisioned
Support MB Settings Page Field Group not showing in settings

  • Creator
    Topic
  • #31795
    Resolved Robert Lane
    Participant
    add_filter( 'rwmb_meta_boxes', 'depts_short_code_page' );
    
    function depts_short_code_page( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'          => __( 'Shortcode Page Name', 'depts_short_code_page' ),
            'id'             => 'shortcode-page-name',
            'settings_pages' => ['shortcode-page'],
            'fields'         => [
                [
                    'name'       => __( 'Shortcode Page Name', 'depts_short_code_page' ),
                    'id'         => $prefix . 'depts_shortcode_page',
                    'type'       => 'post',
                    'post_type'  => ['page'],
                    'field_type' => 'select',
                    'required'   => true,
                    'columns'    => 4,
                ],
            ],
        ];
    
        return $meta_boxes;
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #31797
    Long Nguyen
    Moderator

    Hi Robert,

    Can you please share the code that creates the settings page on your site?

    #31798
    Robert Lane
    Participant
    add_filter( 'mb_settings_pages', 'short_code_page_settings' );
    
    function short_code_page_settings( $settings_pages ) {
        $settings_pages[] = [
            'menu_title'  => __( 'Settings', 'short_code_page_settings' ),
            'option_name' => 'Shortcode Page',
            'position'    => 25,
            'parent'      => 'edit.php?post_type=department',
            'style'       => 'no-boxes',
            'columns'     => 1,
            'icon_url'    => 'dashicons-admin-generic',
        ];
    
        return $settings_pages;
    }
    #31799
    Long Nguyen
    Moderator

    Hi Robert,

    You need to add the parameter id and use the parameter option_name with the name in lowercase and underscore, with no space and special characters.

    Please read more on the documentation https://docs.metabox.io/extensions/mb-settings-page/#using-code

    #31802
    Robert Lane
    Participant

    Why is the ID not being added in the Meta Box AIO when generating the script(s)?

    #31803
    Robert Lane
    Participant

    Not working;

    //Shortcode Field Group
    add_filter( 'rwmb_meta_boxes', 'depts_short_code_page' );
    
    function depts_short_code_page( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'          => __( 'Shortcode Page Name', 'depts_short_code_page' ),
            'id'             => 'shortcode-page-name',
            'settings_pages' => ['shortcode-page'],
            'fields'         => [
                [
                    'name'       => __( 'Shortcode Page Name', 'depts_short_code_page' ),
                    'id'         => $prefix . 'depts_shortcode_page',
                    'type'       => 'post',
                    'post_type'  => ['page'],
                    'field_type' => 'select',
                    'required'   => true,
                    'columns'    => 4,
                ],
            ],
        ];
    
        return $meta_boxes;
    }
    
    //Shortcode Page Settings
    add_filter( 'mb_settings_pages', 'short_code_page_settings' );
    
    function short_code_page_settings( $settings_pages ) {
        $settings_pages[] = [
            'menu_title'  => __( 'Settings', 'short_code_page_settings' ),
            'id' => 'shortcode_page',
            'option_name' => 'shortcode_page',
            'position'    => 25,
            'parent'      => 'edit.php?post_type=department',
            'style'       => 'no-boxes',
            'columns'     => 1,
            'icon_url'    => 'dashicons-admin-generic',
        ];
    
        return $settings_pages;
    }
    #31805
    Robert Lane
    Participant

    Metabox code:
    https://gist.github.com/robertlaneSUDO/b7cb662a31af0b5fab9251987b8dd644

    #31811
    Robert Lane
    Participant

    I got it working! Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.