Wordpress - CMB2 metabox conditional logic
You need to replace the get_option
call with a call to get_post_meta
:
function show_this_field_if_true( $cmb ) {
// Check if other meta value exists
if ( ! get_post_meta( $cmb->object_id, 'other_meta_key_to_check', 1 ) ) {
return false;
}
return true;
}
Keep in mind, this will only work for the initial page-load and will not show the field until you update the other_meta_key_to_check
value and save the page.