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?
- How to Mass Delete Images from Media Library
- Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
- Get posts between custom dates
- Permalink structure by Post Meta value
- How to implement a Google map store locator
- How to integrate video slide using custom post types?
- Deleting Custom Posts & Meta Data on Uninstall
- Widget: Custom Post Type Post Listing Dropdown on Admin Side
- A question on creating filters for custom posts using taxonomy
- Conditional Query of Custom Post Type and custom taxonomy
- will post_id ever change? Can I safely use post_id for custom queries?
- List custom taxonomy specific to one custom post type
- Define new user capability for custom post types?
- How to allow visitors to enter custom post type?
- Post image in WordPress not appearing on home page
- Is it possible to create relational metabox values in a custom post?
- Custom Post Type Query for Sidebar Doesn’t Work on Front Page
- Meta query for custom post type ignored in main query
- How do I create an archive page as a including metadata?
- 2 Templates 1 custom post type according url
- How do I move/order posts with a tag to the end?
- Posting to a Custom Post Type from front end – user generated content
- WordPress sort search results by custom order
- Update Post Meta for a logged in user
- Getting meta in editor plugin, and event triggering issue
- How to duplicate entire custom post type
- A better way to add a meta box to custom post types
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- Restrict Access to Posts based on Custom User and Post Meta Data
- Hide parent categories when clicked, and show it’s childs
- Custom Path/Folder behind a custom post type
- Two Custom Post Types Many to Many Relationship
- get_post_meta not working on publishing
- Time based access control of custom post types – what is good approach?
- Should wp_postmeta meta_key always be unique for a given post_id?
- Show titles, date of all posts on single category page
- how can I register a post_meta field in an existing CPT and then call it again with get_post_custom()?
- get_post_meta returning no value in custom post type alert email
- delete_published_posts does not work
- post meta parameter in post custom-post-type endpoint with restapi
- How to start a new post with custom Taxonomies already set?
- How do I set all of a particular post meta to a value within the custom post type I’m in?
- WooCommerce sort products by the actual product width(not the shipping width)
- Create a custom php page and load it at a specific slug
- Structure of data : CPT + terms
- How to handle paged param in post and custom-post-type?
- Default text in a specific post type, but not visible?
- Metabox not show in categories custom post type cmb2
- WordPress request fiter order by related post’s post_title
- WP_Query custom post type query not showing the exact post type
- Shortcode to display Staff post type based on Location post type and Specialty post type
- Update database from Quick Edit according to Checkbox state of Custom Post Type
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- How to remove post listing page for a custom post type
- How to include term custom meta into the custom taxonomy term permalink structure
- Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Dynamic Custom Fields
- A form that can save/edit after first input
- Show Custom Post Type meta boxes only on Page Edit
- Adding the_content() in custom template email
- Cannot save CPT meta box
- non-hierarchical post type with hierarchical url structure
- Send notification to the admin when new custom post is submitted
- How do i search authors from search form using author’s name
- Allow users to create posts without logging in?
- How to add attributes to taxonomies that may be different from post to post?
- Custom filter function not working with Custom post type
- Pages are not saving due to custom post type
- Migrating a taxonomy’s tags to the native category
- Importing Data from a Non-WordPress database, into WP
- How to produce a sub-page-system in WordPress
- Getting thumbnails of a custom posts featured images in a page-templates metabox
- List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
- Best structure / rewrite rules to achieve the following url
- Remove Post Custom Meta Box
- don’t publish custom post type post if a meta data field isn’t valid
- How does order=asc effect a wp_query (its acting pretty weird in a loop)
- Can’t publish custom post type – “You are not allowed to edit this post.”
- Custom fields for custom post type
- Show future events based on custom field AND order by date
- How to sort posts in a custom post type by title in ascending order by default?
- Sizing textarea field in custom metabox
- Categorise Custom Post Types
- Meta Data for Custom Post Type not saving
- Using preg_replace to filter custom textarea
- Detect inside a custom query the kind of post type to assign custom classes
- Check if post with same meta value exists
- Filter date from post meta when date is in string format
- custom post type vs. conditionally displaying meta boxes for specific terms?