Actually, your code is working, as long as $val == 'on'
.
Did you try debugging by doing echo $val
?
If it’s still not working, try hard refreshing (Ctrl + F5) your webpage, checkboxes tend to keep their state on normal refresh (F5).
Also, please put your code directly on this forum, so the code is always accessible for future viewers 😉
Related Posts:
- How to get custom field image url of specific size
- Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
- What snippet do I need to type to show my ACF field show up on my theme?
- Is there a way to make [Table Of Content] plugin while not using revision data?
- get_post_meta shortcode returns empty field
- How to get post that has non zero or greater than zero meta value
- How do I hide posts across all loops based on the value of a custom field?
- How can I change the meta_key for a particular piece of information?
- WordPress Post Visibility Options for Frontend
- Custom User meta field display
- Bulk update all posts from plugin settings screen
- Execute js files doesn’t seem to work
- WordPress metaboxes – textfield suggestion automatically populated
- Char limit on custom blog-post form? [closed]
- Unable to select image using custom image field type
- Custom fields for custom post type
- Redirect to another page using contact form 7? [closed]
- Every new post/draft has a custom field variable “yst_is_cornerstone” showing
- Custom Post Type Fields
- Meta box losing its value when scheduled post is published
- How to insert multiple postmeta values with one query?
- How do I enforce users to fill a determined custom field using WyPiekacz?
- Mass SQL WordPress Meta Key deletion
- Date format – Meta Box plugin
- get meta value from database by post id
- Adding class to last list item? Not WP generated
- How to Resize the Custom Post Images?
- Amazon.com intergration with WordPress?
- Sticky option for custom post types without using custom fields or plugins
- How to remove bulk actions from custom post type
- Adding custom meta boxes to specified custom post type
- How to select a paragraph other than the 1st to be the post’s excerpt?
- How do we update a custom file upload field with the Advanced Custom Field plugin?
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- Order posts by meta key ( Using ACF )
- How to add fields in the WordPress editor?
- How can I concatenate variables to search results title? [closed]
- WordPress function to add text warning on every pages [closed]
- How to add an extra, independent set of custom fields?
- Price comparison table based on Custom Post Type?
- Show related posts based of current ACF field name in a single page post (a loop within loop)
- How can I store data from custom fields to custom tables?
- Remember the Meta Value With Radio Buttons
- Woocommerce – Change Variable Product Add to Cart to behave like external product using Custom Field (link) [closed]
- Custom Fields for Page Edits
- “After file loaded” action
- Plugin that lets visitors Like a post (not facebook) and stores likes in custom meta?
- Parent Child Custom Fields with Advanced Custom Fields
- grab or load text on demand
- How can I add user profile fields to my mailpress mailout
- Dictionary-style definition list plugin
- Advanced Custom Fields Plugin – Images not displaying
- Link Posts to External URL
- Adding custom Field To The Posts Listing
- How to create repeater field manually, without plugin (ACF Pro)?
- Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
- Why does “updated_post_meta” did not fire when uploading media other than image?
- WordPress Phone Field Check (use numbers, spaces and pluses)
- Can export gallery but can’t import it Wp all import
- Table of contents (TOC) plugin is not showing header tag
- Auto populate a user custom field from another user custom field
- Best approach to make all tags searchable by the wordpress search function
- need to find duplicated meta value in custom filed and view the posts that have the same value
- Create a pdf from the entries in DB
- Help with autofilling field
- Help to Create a Simple Plugin to make a post
- how to find out which plugin disable custom field for post
- Preset custom fields
- What database state changes happen after a post is manually “updated” with no changes?
- Register PODS Custom Field with WPGraphQL [closed]
- Add an action based on custom post meta field
- how to auto random increment for post view
- custom fields not displaying on wordpress site
- WordPress hide post from custom post-type on a single page
- Create multiple posts when a custom post is created
- How to securely controlling data without keeping it in postmeta?
- Why Custom fields description is not working WordPress Version 5.4.2?
- Adding Custom Endpoint in WordPress Rest API
- General Term for this form Field
- How do I change the functionality of an image slider which is part of ACF?
- Make custom post types using ACF
- Problem Advanced Custom Fields PRO
- “Enable Media Replace” plugin does not update serialized object in WPMeta
- Custom Field used to allow a Free Story; no longer works
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- Get and Update Most Meta Value as an array in HTML form
- How to pass multiple custom fields as shortcode’s parameters
- How to create meta fields with more than 1 relation?
- Meta Key array building with multiple input values from fields
- Get all user meta_keys and then group users by matching values
- Custom product page’s style for printing
- Custom plugin issue – Notice: Trying to get property of non-object in
- If I am not writing a theme, how do I add custom fields to a user for a plugin
- Taxonomy question
- Get value from an input field and pass into update_meta_data as $meta_value
- How can I call functions from a custom plugin?
- Creating Nested custom fields
- Problem with conditional woocommerce custom checkout field
- Create Biographies
- Delete postmeta when uninstall/delete plugin