Field Group not showing in settings

Support MB Settings Page Field Group not showing in settingsResolved

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #31795
    Robert LaneRobert 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;
    }
    #31797
    Long NguyenLong Nguyen
    Moderator

    Hi Robert,

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

    #31798
    Robert LaneRobert 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 NguyenLong 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 LaneRobert Lane
    Participant

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

    #31803
    Robert LaneRobert 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 LaneRobert Lane
    Participant

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

    #31811
    Robert LaneRobert Lane
    Participant

    I got it working! Thanks!

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