Be sure to set the value in your markup. You should have.
<input type="checkbox" name="changeposition" value="yes" />
Then, I’d suggest using sanitize_key()
to sanitize.
Keys are used as internal identifiers. Lowercase alphanumeric
characters, dashes and underscores are allowed.
Think of the word yes
, as a key. That’s what you’re expecting is a lowercase alphanumeric value.
See also: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox
If the value attribute was omitted, the submitted data would be given a default value of on, so the submitted data in that case would be subscribe=on.
Related Posts:
- I’m confused about URL sanitization in meta boxes
- Custom-Metaboxes-and-Fields text_url field prepending http://
- Add a Meta Box for uploading a SECOND Featured Image?
- Remove the Featured Image Meta Box
- Remove the Yoast SEO Post Metabox [closed]
- Sample code for validating custom metabox?
- How to add a class to meta box
- Use meta box drag and drop to order items independently
- inside a metabox
- Add Meta box Befoure Post Title
- Tinymce/WordPress is removing all line-breaks?
- Editing the Default Links like “Site Admin” in the Sidebar Meta Section?
- Editing Screen: Make Update or Publish Button Follow The Page
- Custom “Publish” / “Update” button &
- Why can’t I hook into save_posts after admin_init?
- Meta Boxes in Front End Post Submission Form
- Remove a plugin meta box from the dashboard
- How to make multicheck for post/page meta box
- Replace the Post Excerpt Meta Box with a Field in My Custom Meta Box
- How to show post format gallery metabox image caption in the post front end
- Get image captions for images on gallery post format metabox
- Metabox of one post influence setting on other
- Display Single Attachment Image file size, uploaded date, resolution, file-name etc in Sidebar
- Remove a metabox registered by another plugin – Woocommerce [closed]
- Possible to limit custom meta boxes depending on what page template is used?
- Adding Metaboxes – so much code is there a shorter DRY way?
- Show or hide custom meta box not work with Gutenberg
- unable to save post meta on single field with multiple selects
- Add Slug Metabox to posts for contributors
- Hide meta box based on post format
- TinyMCE with custom buttons on a meta box
- How do i hide the auto-generated custom field that’s created when update_post_meta() is called?
- WPAlchemy: How to output values?
- save_post not working with attachments
- get $post (object,parts/values) in meta-box
- How to get meta box values – WP tuts tutorial
- How to add categories to page editor?
- Change Metabox Title
- Having trouble getting my meta data to save
- add wp_editor to custom_meta_box
- Show how many images are attached to a post/page on compose page
- Metabox context for page post type
- Show Meta Box On Specific Page Template
- How to use MarkDown in a custom textarea field?
- On click hide group of metabox, similar to screen options checkbox?
- Adding meta box without add_meta_box – is this bad?
- How to make a stand-alone button to the post edit view
- saving data entered into a Metabox into an array? for use with for/each output.
- Cusotm MetaBox content not getting saved
- How to get the meta box name and value
- wp_editor loses data, perhaps an html_entity_decode problem?
- My custom write panels won’t save data. What am I missing?
- How to position user meta data field
- How to create a button click counter meta box?
- Display Content if Meta Checkbox is checked?
- meta box & callback function
- $_GET & $post_ID
- get_post_meta as a list for drop down search filter
- add_post_meta | update_post_meta | Via the frontend
- MetaBox with Editor instead of textarea – html not saved [closed]
- Use meta boxes inside an archive page template for Woocommerce
- Why do Metabox use Nonces?
- multi custom fields and taxonomy search
- Migrating from metaboxes to wp_editor()
- conditionally echo in meta box data loop
- Front end post and upload file, image for users without plugin
- Meta Box multi checkbox in template
- remove a single post_meta
- Dynamic number of fields in a meta box
- How to make a metabox that contains link categories?
- how to log in to WP if the “Log in” link under Meta is missing
- Echo 2 values from one key in Array with get_post_custom
- meta box pop up upload button wont work
- Add metabox to pages that use custom template in WordPress
- Meta Box – Javascript Datatable
- Metabox on a custom page – How to include the appropriate default scripts and styles?
- custom metabox nonce verification fails
- Extensible add_meta_box with apply filters
- use post meta in add_meta_boxes action
- Generating image sizes when uploading through wp.media
- Why is the text displaying, but not the textarea field itself?
- Meta box checkbox won’t save
- add_post_meta not saved
- Set post title to same value as a tow meta box
- add_post_meta Adds post meta but the value is blank
- Best practices for meta box placement?
- Echo order box (in pages)
- WP Alchemy – stripping my paragraph tags from textarea metaboxes
- Meta boxes not showing on custom post type. Blank page?
- Tags meta box don’t show when creating a new post type
- dynamically get post attachment while editing
- Remove duplicated values from meta box values
- Setting Event to Expire Using Custom Metabox
- Drop down menu’s not saving using Custom Meta Boxs in WordPress
- Remove Title, Editor and Meta Box Support Based on Post Formats
- Custom select box meta field
- Metadata in loops
- Saving an upload media meta box field
- Conditonally check if Custom Meta Box has input
- Metaboxes – why they don’t render php in expected manner?