Save checkbox value in metabox

This isn’t a WP question, but moreso a general form issue. Regardless, a checkbox will not pass anything if unchecked, and 1 or on if checked.

// Sanitize user input.
$my_data = $_POST['home_slider_display'] ? true : false;

// Update the meta field in the database.
update_post_meta( $post_id, 'home_slider_display', $my_data );

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)