Problem with MB Settings Page value
Support › MB Settings Page › Problem with MB Settings Page value
- This topic has 1 reply, 2 voices, and was last updated 5 years, 8 months ago by
Anh Tran.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
September 2, 2019 at 4:34 PM #15945
dave.meta
ParticipantHello, 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
September 3, 2019 at 8:41 AM #15952Anh Tran
KeymasterHi Dave,
In your settings page, you set
'option_name' => 'Avantage Courtage'
. Please change it toac-setting
. It's the option name that you will use in theget_option
orrwmb_meta
function. -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.