Custom meta field checkbox
-
I’m trying to create a meta box checkbox but I can’t get it to work.. I’m using the function reference at https://codex.www.ads-software.com/Function_Reference/add_meta_box
The code I’m using for the check-box meta is,
echo '<label for="myplugin_new_field">' . __("Description for this field", 'myplugin_textdomain' ) . '</label> '; echo '<input type="checkbox" name="myplugin_new_field" id="myplugin_new_field" value="yes"'; if ( get_post_meta('myplugin_new_field', true ) == "yes" ) echo ' checked="checked"'; echo '" style="width: auto;" />'; }
The checkbox appears in edit post pages without any errors. I check it but after I update the post it becomes unchecked.
Not sure what I’m doing wrong here..
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Custom meta field checkbox’ is closed to new replies.