CMB2 has an option to use as a option page.

i’m looking in the example files, and on the wiki page but even copying and pasting the example on the files it not work.

i’m probably missing something, but i can’t find what it is, i already spent two days trying to make this work.

Following the wiki and the example i modified to this code

add_action( 'cmb2_admin_init', 'yourprefix_register_theme_options_metabox' );
function yourprefix_register_theme_options_metabox() {

    $option_key = 'wherever';

    $cmb = new_cmb2_box( array(
        'id'=> $option_key . '_theme_options-page',
        'object_types' => array( 'options-page' ),
        'hookup'  => false,
        'menu_title' => 'Site Options',
        'parent_slug' => 'tools.php',
        'capability' => 'manage_options'
    ) );

    $cmb->add_field( array(
        'name'    => 'Site Background Color',
        'desc'    => 'field description',
        'id'      => 'bg_color',
        'type'    => 'colorpicker',
        'default' => '#ffffff'
    ) );


Any leads on why it’s not working?

Read more here: CMB2 option-page parameter


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: