Custom Metaboxes and Fields (CMB) will create metaboxes and forms with custom fields that will blow your mind. This is version 2.0 and has been completely rewritten.
Hello,
I'm using cmb object type as page, purpose for theme option.'object_types' => array( 'page' ),
But can't display in post loop.if ( have_posts() ) : while ( have_posts() ) : the_post();
if(get_post_meta( get_the_ID(), 'CUSTOM FIELD', 1 )) {
echo "YES!";
}
endwhile; endif;
Outside of post loop works ok, anyone please help me.
Hi everybody. I've already implements this code:
function cmb2_post_search_ajax_metaboxes_example() {
$example_meta = new_cmb2_box( array(
'id' => 'cmb2_post_search_ajax_field',
'title' => __( 'Related Posts', 'cmb2' ),
'object_types' => array( 'movie' ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
) );
$example_meta->add_field( array(
'name' => ( 'Example Multiple', 'cmb2' ),
'id' => 'cmb2_post_search_ajax_demo_multiple',
'type' => 'post_search_ajax',
'desc' => ( '(Start typing post title)', 'cmb2' ),
// Optional :
'limit' => 10, // Limit selection to X items only (default 1)
'sortable' => true, // Allow selected items to be sortable (default false)
'query_args' => array(
'post_type' => array( 'movie' ),
'post_status' => array( 'publish' ),
'posts_per_page' => -1
)
) );
$example_meta->add_field( array(
'name' => ( 'Example Single', 'cmb2' ),
'id' => 'cmb2_post_search_ajax_demo_single',
'type' => 'post_search_ajax',
'desc' => ( '(Start typing post title)', 'cmb2' ),
// Optional :
'limit' => 1, // Limit selection to X items only (default 1)
'sortable' => false, // Allow selected items to be sortable (default false)
'query_args' => array(
'post_type' => array( 'movie' ),
'post_status' => array( 'publish' ),
'posts_per_page' => -1
)
) );
}
add_action( 'cmb2_init', 'cmb2_post_search_ajax_metaboxes_example' );