• Resolved chlara

    (@chlara)


    I’m using CMB2 plugin to add select metaboxes into a post. The metabox work fine on the post editor. But failed to render and displaying on post page.

    The code for post editor

    add_action( 'cmb2_admin_init', 'postintro_metabox' );
        function myweb_postintro_metabox() {
        $myweb_grouppf = new_cmb2_box( array(
             'id'            => 'postintro_metabox',
             'title'         => __('Post Intro', 'MYWEB'),
             'object_types' => array( 'post', ), // Post type
             'context'       => 'normal',
             'priority'      => 'high',
             'show_names'    => true, // Show field names on the left
        ) );  
    
        $myweb_grouppf->add_field( array(
            'name'             => 'Test Select',
            'desc'             => 'Select an option',
            'id'               => 'wiki_test_select',
            'type'             => 'select',
            'show_option_none' => true,
            'default'          => 'custom',
            'options'          => array(
                'standard' => __( 'Option One', 'cmb2' ),
                'custom'   => __( 'Option Two', 'cmb2' ),
                'none'     => __( 'Option Three', 'cmb2' ),
            ),
        ) );
    
        }

    Then I try to call on my post with this code:

    <?php echo ( get_post_meta( get_the_ID(), ‘wiki_test_select’, true ) ); ?>

    Could you please help me out? I appreciate it.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Render and display select on post page’ is closed to new replies.