You will need to save them as an array and currently your HTML is not in the correct format to do this.
<label for="my-cpt-32">
<input type="checkbox" name="cpt_ids[]" value="32" id="my-cpt-32" />
My CPT #32
</label>
<label for="my-cpt-41">
<input type="checkbox" name="cpt_ids[]" value="41" id="my-cpt-41" />
My CPT #41
</label>
<label for="my-cpt-43">
<input type="checkbox" name="cpt_ids[]" value="42" id="my-cpt-43" />
My CPT #43
</label>
When this get’s $_POST’ed you will have an array of checked values, make sure to check it is ‘set’ e.g. isset( $_POST['cpt_ids'] )
.
If you ticked 41 & 43 you would get array like this:
array(
[0] => 41,
[1] => 43
)
which you can use to save in your custom field, or a secondary table etc.
I hope this helps!
Related Posts:
- what is the correct way to compare dates in a WP query_posts meta_query
- Correctly delete posts with meta and attachments [duplicate]
- Custom Post Type with Input fields to seperate table on database.
- Get all posts from custom post type and insert in select input as metabox
- Having trouble with custom post type / meta box
- Custom search for custom post meta with pre_get_posts interferes with WP search
- changing meta value and meta key of price field
- Update postmeta Parent when post_status child change
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- Stored meta from attachment, video length?
- Ordering posts having multiple post-meta date fields
- Admin Post Update Redirection to Posts Screen
- modify all posts of a category to “no comments allowed”
- How to not allow custom roles to edit published custom post types?
- Assign Page Template Within A Custom Post Type
- Single Page WordPress CSS and JS links
- [Plugin: Posts 2 Posts] Changing display order of connections
- Disable dragging of metaboxes in custom post types?
- Error after deleting Custom Post Type with a function (no trash used)
- How to delete all posts from a custom post type?
- Structure for projects and clients
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Why is my custom loop not filtering correctly nor paginating?
- Custom post types with custom directories
- Saving repeated option values in a custom query
- How to customize admin posts based on the user who is logged in
- Custom Post Type | Fatal Error on register_post_type()
- How to post twitter like updates on wordpress
- How to get all `supports` attributes by post type?
- Count posts with specific term_meta
- Deleting Custom Post type data using mySQL command
- My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
- Ordering posts in Search & taxonomy by post_meta
- How inefficient is it to use a Custom Post for 4-5 sentences & pull all to 1 page?
- Permalink structure by Post Meta value
- A question on creating filters for custom posts using taxonomy
- 2 Templates 1 custom post type according url
- Posting to a Custom Post Type from front end – user generated content
- WordPress sort search results by custom order
- Restrict Access to Posts based on Custom User and Post Meta Data
- How to start a new post with custom Taxonomies already set?
- WooCommerce sort products by the actual product width(not the shipping width)
- Create a custom php page and load it at a specific slug
- Adding the_content() in custom template email
- Pages are not saving due to custom post type
- Migrating a taxonomy’s tags to the native category
- Show future events based on custom field AND order by date
- custom post type vs. conditionally displaying meta boxes for specific terms?
- Edit the_content() function so to add a div wrapper
- Number of posts in the archive
- Replace dynamically content in a custom database table when a custom post is created
- create custom meta box with default value
- Save and user submitted data from a form and display them in the wp backend
- Issue on Working with Metabox – Checkbox to enable Sale Items
- How to move a post to different post type with all meta data?
- Custom post type menu
- WP API Response does not show my registered metadata
- How to detect that the save_post hook is calling the callback associated to the current edit post page only
- Problem with adding custom post type meta to header by plugin
- How to call a post’s metadata in shortcode.php?
- Echo custom post meta from options array
- Value of post meta dropdown is not showing in WordPress
- WP_Meta_Query object with conditionals
- Trying to write shortcode with get_post_meta but isn’t working
- Function to add custom HTML into head in custom post-type list page
- What is the best way to manage small blocks of content on my home page?
- One post auto attached to many another items
- How do I “trash” a custom post type post while logged in as Admin
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- Is it possible to create 2 unique titles for an Events custom post type: Upcoming Events and Past Events?
- Show posts from WP Custom Post Type selected from a field in a metabox
- Peepso: Add extra data field (custom post meta) to postbox
- wp delete duplicate entries of custom post types every 15 minutes
- Change picture attachment meta of all occurrences of a picture
- Unknown Post Meta Records
- Get Previous Post based on Custom Field Name, for Custom Post Type
- Saving custom post types post_meta over REST-API fails
- Attempting to create custom “post” template, getting a 500 internal server error
- connect users to Custom post types
- Stripe multiple transactions
- Custom Pagination based on Custom Post Type
- Custom user roles
- One Post with different content, depending on a Page
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Edit is changing my custom’s post type parent id
- Registering an optional custom post type from a plugin
- WordPress custom post type
- Edit post meta direct from post.php?
- Custom metabox value not saving
- Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
- Cannot modify a registered custom post type rewrite slug
- Change the contents of a dropdown through the admin panel?
- Select Menu for Custom post Type does not save
- fetch meta fields inside a widget
- Inserting two categories
- Use a Variable in update_post_meta as the $meta_key
- How to delete unnecessary custom post types in the UI
- Advise on Custom Taxonomies and Structure