title: WordPress CMB2 - Get Option Value
body: <p>I am using the example from the CMB2 snippets library to add a theme options page in WordPress</p>
  
  <pre><code>/**
   * Hook in and register a metabox to handle a theme options page and adds a menu item.
   */
  function yourprefix_register_main_options_metabox() {
  
      /**
       * Registers main options page menu item and form.
       */
      $args = array(
          'id'           =&gt; 'yourprefix_main_options_page',
          'title'        =&gt; 'Main Options',
          'object_types' =&gt; array( 'options-page' ),
          'option_key'   =&gt; 'yourprefix_main_options',
          'tab_group'    =&gt; 'yourprefix_main_options',
          'tab_title'    =&gt; 'Main',
      );
  
      // 'tab_group' property is supported in &gt; 2.4.0.
      if ( version_compare( CMB2_VERSION, '2.4.0' ) ) {
          $args['display_cb'] = 'yourprefix_options_display_with_tabs';
      }
  
      $main_options = new_cmb2_box( $args );
  
      /**
       * Options fields ids only need
       * to be unique within this box.
       * Prefix is not needed.
       */
      $main_options-&gt;add_field( array(
          'name'    =&gt; 'Site Background Color',
          'desc'    =&gt; 'field description (optional)',
          'id'      =&gt; 'bg_color',
          'type'    =&gt; 'colorpicker',
          'default' =&gt; '#ffffff',
      ) );
  
      /**
       * Registers secondary options page, and set main item as parent.
       */
      $args = array(
          'id'           =&gt; 'yourprefix_secondary_options_page',
          'menu_title'   =&gt; 'Secondary Options', // Use menu title, &amp; not title to hide main h2.
          'object_types' =&gt; array( 'options-page' ),
          'option_key'   =&gt; 'yourprefix_secondary_options',
          'parent_slug'  =&gt; 'yourprefix_main_options',
          'tab_group'    =&gt; 'yourprefix_main_options',
          'tab_title'    =&gt; 'Secondary',
      );
  
      // 'tab_group' property is supported in &gt; 2.4.0.
      if ( version_compare( CMB2_VERSION, '2.4.0' ) ) {
          $args['display_cb'] = 'yourprefix_options_display_with_tabs';
      }
  
      $secondary_options = new_cmb2_box( $args );
  
      $secondary_options-&gt;add_field( array(
          'name'    =&gt; 'Test Radio',
          'desc'    =&gt; 'field description (optional)',
          'id'      =&gt; 'radio',
          'type'    =&gt; 'radio',
          'options' =&gt; array(
              'option1' =&gt; 'Option One',
              'option2' =&gt; 'Option Two',
              'option3' =&gt; 'Option Three',
          ),
      ) );
  
      /**
       * Registers tertiary options page, and set main item as parent.
       */
      $args = array(
          'id'           =&gt; 'yourprefix_tertiary_options_page',
          'menu_title'   =&gt; 'Tertiary Options', // Use menu title, &amp; not title to hide main h2.
          'object_types' =&gt; array( 'options-page' ),
          'option_key'   =&gt; 'yourprefix_tertiary_options',
          'parent_slug'  =&gt; 'yourprefix_main_options',
          'tab_group'    =&gt; 'yourprefix_main_options',
          'tab_title'    =&gt; 'Tertiary',
      );
  
      // 'tab_group' property is supported in &gt; 2.4.0.
      if ( version_compare( CMB2_VERSION, '2.4.0' ) ) {
          $args['display_cb'] = 'yourprefix_options_display_with_tabs';
      }
  
      $tertiary_options = new_cmb2_box( $args );
  
      $tertiary_options-&gt;add_field( array(
          'name' =&gt; 'Test Text Area for Code',
          'desc' =&gt; 'field description (optional)',
          'id'   =&gt; 'textarea_code',
          'type' =&gt; 'textarea_code',
      ) );
  
  }
  add_action( 'cmb2_admin_init', 'yourprefix_register_main_options_metabox' );
  
  /**
   * A CMB2 options-page display callback override which adds tab navigation among
   * CMB2 options pages which share this same display callback.
   *
   * @param CMB2_Options_Hookup $cmb_options The CMB2_Options_Hookup object.
   */
  function yourprefix_options_display_with_tabs( $cmb_options ) {
      $tabs = yourprefix_options_page_tabs( $cmb_options );
      ?&gt;
      &lt;div class="wrap cmb2-options-page option-&lt;?php echo $cmb_options-&gt;option_key; ?&gt;"&gt;
          &lt;?php if ( get_admin_page_title() ) : ?&gt;
              &lt;h2&gt;&lt;?php echo wp_kses_post( get_admin_page_title() ); ?&gt;&lt;/h2&gt;
          &lt;?php endif; ?&gt;
          &lt;h2 class="nav-tab-wrapper"&gt;
              &lt;?php foreach ( $tabs as $option_key =&gt; $tab_title ) : ?&gt;
                  &lt;a class="nav-tab&lt;?php if ( isset( $_GET['page'] ) &amp;&amp; $option_key === $_GET['page'] ) : ?&gt; nav-tab-active&lt;?php endif; ?&gt;" href="&lt;?php menu_page_url( $option_key ); ?&gt;"&gt;&lt;?php echo wp_kses_post( $tab_title ); ?&gt;&lt;/a&gt;
              &lt;?php endforeach; ?&gt;
          &lt;/h2&gt;
          &lt;form class="cmb-form" action="&lt;?php echo esc_url( admin_url( 'admin-post.php' ) ); ?&gt;" method="POST" id="&lt;?php echo $cmb_options-&gt;cmb-&gt;cmb_id; ?&gt;" enctype="multipart/form-data" encoding="multipart/form-data"&gt;
              &lt;input type="hidden" name="action" value="&lt;?php echo esc_attr( $cmb_options-&gt;option_key ); ?&gt;"&gt;
              &lt;?php $cmb_options-&gt;options_page_metabox(); ?&gt;
              &lt;?php submit_button( esc_attr( $cmb_options-&gt;cmb-&gt;prop( 'save_button' ) ), 'primary', 'submit-cmb' ); ?&gt;
          &lt;/form&gt;
      &lt;/div&gt;
      &lt;?php
  }
  
  /**
   * Gets navigation tabs array for CMB2 options pages which share the given
   * display_cb param.
   *
   * @param CMB2_Options_Hookup $cmb_options The CMB2_Options_Hookup object.
   *
   * @return array Array of tab information.
   */
  function yourprefix_options_page_tabs( $cmb_options ) {
      $tab_group = $cmb_options-&gt;cmb-&gt;prop( 'tab_group' );
      $tabs      = array();
  
      foreach ( CMB2_Boxes::get_all() as $cmb_id =&gt; $cmb ) {
          if ( $tab_group === $cmb-&gt;prop( 'tab_group' ) ) {
              $tabs[ $cmb-&gt;options_page_keys()[0] ] = $cmb-&gt;prop( 'tab_title' )
                  ? $cmb-&gt;prop( 'tab_title' )
                  : $cmb-&gt;prop( 'title' );
          }
      }
  
      return $tabs;
  }
  </code></pre>
  
  <p>This works great, but I can't figure out how to actually get one of these values and display it in a theme.  Anyone have an example?</p>