Closed MikeiLL closed 3 years ago
Hey, man. Sorry to bother. I've had a quick look at the CMB2 docs and am not quite finding how to access the options set in the cmb2 settings pages:
<div id="tabs-1" class="wrap"> <?php $cmb = new_cmb2_box( array( 'id' => MMC_TEXTDOMAIN . '_options', 'hookup' => false, 'show_on' => array( 'key' => 'options-page', 'value' => array( MMC_TEXTDOMAIN ), ), 'show_names' => true, ) ); $cmb->add_field( array( 'name' => __( 'Videos per paginated segment', MMC_TEXTDOMAIN ), 'desc' => __( 'Number if on demand classes to load at a time.', MMC_TEXTDOMAIN ), 'id' => 'videos_per_segment', 'type' => 'text', 'default' => 20, ) ); cmb2_metabox_form( MMC_TEXTDOMAIN . '_options', MMC_TEXTDOMAIN . '-settings' ); ?> </div>
When I try to get the options, it just returns the default:
$eod_options = cmb2_get_option( MMC_TEXTDOMAIN . '_options', 'videos_per_segment', 'default one' ); var_dump($eod_options); $opts = get_option( MMC_TEXTDOMAIN . '_options', 'default too' ); var_dump($opts);
I'm sure I'm missing something simple.
Because -options is the metabox ID in CMB not the one with the value. You need to use -settings to get the values.
-options
-settings
Hey, man. Sorry to bother. I've had a quick look at the CMB2 docs and am not quite finding how to access the options set in the cmb2 settings pages:
When I try to get the options, it just returns the default:
I'm sure I'm missing something simple.