Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Custom Post Type, Saving Multiple Checkboxes

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:

  1. what is the correct way to compare dates in a WP query_posts meta_query
  2. Correctly delete posts with meta and attachments [duplicate]
  3. Custom Post Type with Input fields to seperate table on database.
  4. Get all posts from custom post type and insert in select input as metabox
  5. Having trouble with custom post type / meta box
  6. Custom search for custom post meta with pre_get_posts interferes with WP search
  7. changing meta value and meta key of price field
  8. Update postmeta Parent when post_status child change
  9. How to Disable option of meta field if that option is selected for any other post in custom post type?
  10. Stored meta from attachment, video length?
  11. How to Mass Delete Images from Media Library
  12. Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
  13. Get posts between custom dates
  14. Permalink structure by Post Meta value
  15. How to implement a Google map store locator
  16. How to integrate video slide using custom post types?
  17. Deleting Custom Posts & Meta Data on Uninstall
  18. Widget: Custom Post Type Post Listing Dropdown on Admin Side
  19. A question on creating filters for custom posts using taxonomy
  20. Conditional Query of Custom Post Type and custom taxonomy
  21. will post_id ever change? Can I safely use post_id for custom queries?
  22. List custom taxonomy specific to one custom post type
  23. Define new user capability for custom post types?
  24. How to allow visitors to enter custom post type?
  25. Post image in WordPress not appearing on home page
  26. Is it possible to create relational metabox values in a custom post?
  27. Custom Post Type Query for Sidebar Doesn’t Work on Front Page
  28. Meta query for custom post type ignored in main query
  29. How do I create an archive page as a including metadata?
  30. 2 Templates 1 custom post type according url
  31. How do I move/order posts with a tag to the end?
  32. Posting to a Custom Post Type from front end – user generated content
  33. WordPress sort search results by custom order
  34. Update Post Meta for a logged in user
  35. Getting meta in editor plugin, and event triggering issue
  36. How to duplicate entire custom post type
  37. A better way to add a meta box to custom post types
  38. Use same slug base for Custom Post Type posts, and multiple taxonomy terms
  39. Restrict Access to Posts based on Custom User and Post Meta Data
  40. Hide parent categories when clicked, and show it’s childs
  41. Custom Path/Folder behind a custom post type
  42. Two Custom Post Types Many to Many Relationship
  43. get_post_meta not working on publishing
  44. Time based access control of custom post types – what is good approach?
  45. Should wp_postmeta meta_key always be unique for a given post_id?
  46. Show titles, date of all posts on single category page
  47. how can I register a post_meta field in an existing CPT and then call it again with get_post_custom()?
  48. get_post_meta returning no value in custom post type alert email
  49. delete_published_posts does not work
  50. post meta parameter in post custom-post-type endpoint with restapi
  51. How to start a new post with custom Taxonomies already set?
  52. How do I set all of a particular post meta to a value within the custom post type I’m in?
  53. WooCommerce sort products by the actual product width(not the shipping width)
  54. Create a custom php page and load it at a specific slug
  55. Structure of data : CPT + terms
  56. How to handle paged param in post and custom-post-type?
  57. Default text in a specific post type, but not visible?
  58. Metabox not show in categories custom post type cmb2
  59. WordPress request fiter order by related post’s post_title
  60. WP_Query custom post type query not showing the exact post type
  61. Shortcode to display Staff post type based on Location post type and Specialty post type
  62. Update database from Quick Edit according to Checkbox state of Custom Post Type
  63. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  64. How to remove post listing page for a custom post type
  65. How to include term custom meta into the custom taxonomy term permalink structure
  66. Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
  67. How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
  68. Dynamic Custom Fields
  69. A form that can save/edit after first input
  70. Show Custom Post Type meta boxes only on Page Edit
  71. Adding the_content() in custom template email
  72. Cannot save CPT meta box
  73. non-hierarchical post type with hierarchical url structure
  74. Send notification to the admin when new custom post is submitted
  75. How do i search authors from search form using author’s name
  76. Allow users to create posts without logging in?
  77. How to add attributes to taxonomies that may be different from post to post?
  78. Custom filter function not working with Custom post type
  79. Pages are not saving due to custom post type
  80. Migrating a taxonomy’s tags to the native category
  81. Importing Data from a Non-WordPress database, into WP
  82. How to produce a sub-page-system in WordPress
  83. Getting thumbnails of a custom posts featured images in a page-templates metabox
  84. List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
  85. Best structure / rewrite rules to achieve the following url
  86. Remove Post Custom Meta Box
  87. don’t publish custom post type post if a meta data field isn’t valid
  88. How does order=asc effect a wp_query (its acting pretty weird in a loop)
  89. Can’t publish custom post type – “You are not allowed to edit this post.”
  90. Custom fields for custom post type
  91. Show future events based on custom field AND order by date
  92. How to sort posts in a custom post type by title in ascending order by default?
  93. Sizing textarea field in custom metabox
  94. Categorise Custom Post Types
  95. Meta Data for Custom Post Type not saving
  96. Using preg_replace to filter custom textarea
  97. Detect inside a custom query the kind of post type to assign custom classes
  98. Check if post with same meta value exists
  99. Filter date from post meta when date is in string format
  100. custom post type vs. conditionally displaying meta boxes for specific terms?
Categories custom-post-types Tags custom-post-types, customization, input, post-meta
How to edit pages after installing WP
How to use if condition to change $table_prefix in wp_config.php

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress