hi,
Almost there ??
My problem is I’m trying to make the checkbox value the same as the label and failing ??
The checkbox value is numeric while the label is the title of the custom post type (as intended). I’d like the value and the label to be the sane ie. Both to be the title of the custom post type.
Image below to show what I’m trying to do ??
Image
Code below:
function cmb2_get_post_options( $query_args ) {
$args = wp_parse_args( $query_args, array(
'post_type' => 'activity',
'numberposts' => -1,
) );
$posts = get_posts( $args );
$post_options = array();
if ( $posts ) {
foreach ( $posts as $post ) {
$post_options[ $post->ID ] = $post->post_title;
}
}
return $post_options;
}
$cmb2->add_field( array(
'name' => __( 'Activities in this package', 'cmb2' ),
'desc' => __( 'select the relevant activities', 'cmb2' ),
'id' => $prefix . 'post_multicheckbox',
'type' => 'multicheck',
'options' => cmb2_get_post_options( array( 'post_type' => 'activity', 'numberposts' => -1 , 'orderby' => 'name', 'order' => 'ASC' ) )
)
);
}
Normally the checkbox option is like the code below, but when I try to repeat this format everything breaks.
'options' => array(
'check1' => 'Check One',
'check2' => 'Check Two',
'check3' => 'Check Three',
)
Here’s hoping – thanks ??