Problem with MB Settings Page value

Support MB Settings Page Problem with MB Settings Page value

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15945
    dave.metadave.meta
    Participant

    Hello, I have a problem with the Meta Box Settings Page plugin, I create all the field and there are display on the admin page but I try to display it on functions.php or in header.php, and it doesn't work... I use OceanWP theme, I don't know if is the problem ?

    /* META BOX SETTINGS */
    
    // Register settings page. In this case, it's a theme options page
    add_filter( 'mb_settings_pages', 'ac_options_page' );
    function ac_options_page( $settings_pages ) {
        $settings_pages[] = array(
            'id'          => 'ac-setting',
            'option_name' => 'Avantage Courtage',
            'menu_title'  => 'Avantage Courtage',
            'icon_url'    => 'dashicons-admin-settings',
            'parent'      => 'themes.php',
            'style'       => 'boxes',
            'columns'     => 1,
            'tabs'        => array(
                'taux' => 'Taux',
            ),
        );
        return $settings_pages;
    }
    
    // Register meta boxes and fields for settings page
    add_filter( 'rwmb_meta_boxes', 'prefix_options_meta_boxes' );
    function prefix_options_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = array(
            'id'             => 'ac-tx',
            'title'          => 'Taux du Calculateur',
            'settings_pages' => 'ac-setting',
            'tab'            => 'taux',
    
            'fields' => array(
                array(
                    'name' => 'Taux sur 15 ans',
                    'id'   => 'ac_tx_15',
                    'type' => 'text',
                ),
                array(
                    'name' => 'Taux sur 20 ans',
                    'id'   => 'ac_tx_20',
                    'type' => 'text',
                ),
                array(
                    'name' => 'Taux sur 25 ans',
                    'id'   => 'ac_tx_25',
                    'type' => 'text',
                ),
            ),
        );
        return $meta_boxes;
    }
    
    function get_theme_option($field_id)
    {
        global $settings;
    
        $value = (isset($settings[ $field_id ])) ? $settings[ $field_id ] : false;
    
        return $value;
    }
             $settings = get_option('ac-setting');
                var_dump($settings);
                var_dump(get_theme_option('ac_tx_15'));
                var_dump(rwmb_meta('ac_tx_20', array( 'object_type' => 'setting' ), 'ac-setting' )); 

    Can you help me ?

    Thanks

    #15952
    Anh TranAnh Tran
    Keymaster

    Hi Dave,

    In your settings page, you set 'option_name' => 'Avantage Courtage'. Please change it to ac-setting. It's the option name that you will use in the get_option or rwmb_meta function.

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