I have a problem get the image with cmb2, I have tried in many ways without successm according to the documentation, this is fine, what can I be doing wrong?
add_action( 'cmb2_admin_init', 'cmb2_sample_metaboxes2' );
function cmb2_sample_metaboxes2() {
// Start with an underscore to hide fields from custom fields list
$prefix = '_textinfo_';
$cmb = new_cmb2_box( array(
'id' => 'book_metabox',
'title' => __('information', 'cmb2' ),
'object_types' => array( 'book', 'page' ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
) );
$cmb->add_field( array(
'name' => 'Book Name',
'id' => $prefix . 'book',
'type' => 'textarea',
'sanitization_cb' => false,
) );
$cmb->add_field( array(
'name' => 'Book Image',
'id' => $prefix . 'bookimg',
'type' => 'file',
) ); }
does not work
<?php wp_get_attachment_image( get_post_meta( get_the_ID(), '_textinfo_bookimg_id', 1 ), 'thumbnail' ); ?>