Welcome to WordPress SO.
You may already have solved the issue as suggested by @Stevish, but just in order to avoid promoting the idea of checkboxes somehow being bad or difficult, I’d like to point out, that they’re perfectly okay and logical. 🙂
What is the problem in your first snippet, is the additional closing square bracket ‘]’ in the value, which would cause a syntax error and thus PHP Fatal error.
Change this:
update_post_meta( $post_id, 'checkbox_1', 'yes'] );
to this:
update_post_meta( $post_id, 'checkbox_1', 'yes' );
Also, a handy way to deal with single value metadata is to specify the $key
and the $single
parameter like this:
$value = get_post_meta( $post_id, 'checkbox_1', true );
That way you get the single value, and not an array where your value is the [0]. That way you can skip many if( isset( $meta['whatever'][0] ) )
kind of checks. 🙂