Save meta box value

 In
<?php /** * Saves the custom meta input */ function sm_meta_save( $post_id ) { // Checks save status $is_autosave = wp_is_post_autosave( $post_id ); $is_revision = wp_is_post_revision( $post_id ); $is_valid_nonce = ( isset( $_POST[ 'sm_nonce' ] ) && wp_verify_nonce( $_POST[ 'sm_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false'; // Exits script depending on save status if ( $is_autosave || $is_revision || !$is_valid_nonce ) { return; } // Checks for input and saves if( isset( $_POST[ 'meta-checkbox' ] ) ) { update_post_meta( $post_id, 'meta-checkbox', 'yes' ); } else { update_post_meta( $post_id, 'meta-checkbox', '' ); } } add_action( 'save_post', 'sm_meta_save' ); ?>
Recent Posts
Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.