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

How to Disable option of meta field if that option is selected for any other post in custom post type?

If I understood you correctly, you want to prevent users from selecting a radio option, which have been already selected on another post, when the user is adding a new post, right?

I think you need to first check if the user is on the “add new” page in your metabox. You can do that with the global $pagenow variable. That will give you post-new.php when you’re on the “add new” page.

(Side note: You could also wrap the check in a custom function like seen here, How to determine whether we are in add New page/post/CPT or in edit page/post/CPT in wordpress admin?)

Then do a conditional check to make sure it is the “add new” page. If so get all the values that have already been selected on other posts. This is somewhat unfamiliar territory for me, but I found a promising old thread on the matter – How to get a meta value from all post

I think the custom get_meta_values function shared on the old thread should do the trick for you. It might need some tweaking, but test it and see how it works.

And third, when you have the array of previously selected values, you can use it to mark matching options as selected / disabled.

Hopefully I didn’t miss the mark too badly and answered you’re question. I’m sorry I don’t have any code of my own to share with you. This is the idea and concept that popped into my mind after reading your question.

Related Posts:

  1. what is the correct way to compare dates in a WP query_posts meta_query
  2. Advanced search form with filters for custom taxonomies and custom fields
  3. don’t publish custom post type post if a meta data field isn’t valid
  4. Correctly delete posts with meta and attachments [duplicate]
  5. Custom field values deleted when trashing custom post type
  6. How to get all custom fields of any post type
  7. Admin Area Custom Type Search By Meta Fields Without Title & Content
  8. Search multiple custom fields by using meta_query
  9. How do I Paginate Search Results for Custom Post Types?
  10. How Can I save multiple records in same meta key?
  11. Add custom field to media attachment image attribute in post editor
  12. Detect meta value changes when post is updated (post_updated)
  13. Search everything (posts, pages, tags, cpt, meta)
  14. Custom Post Type with Custom Title
  15. How can I customize “Pages” admin (edit.php) and “Edit Page” admin (post.php) for bulk edit of custom content type?
  16. How to get source of custom meta image?
  17. Having trouble with custom post type / meta box
  18. Displaying Meta Box Image
  19. ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
  20. Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
  21. Community and User Generated Content Website: Have been thinking about Drupal but leaning on WordPress heavily
  22. Related links – from other sites
  23. Saving repeated option values in a custom query
  24. Custom Post Type, Saving Multiple Checkboxes
  25. Custom search for custom post meta with pre_get_posts interferes with WP search
  26. Create a random unique 6 digit number as custom field for custom post type
  27. Assigning the same custom meta box to multiple post types
  28. Dynamically add / duplicate custom meta in custom post types
  29. how to interconnect custom post types?
  30. How to insert content from another Custom Post type into Post?
  31. How to structure a site with product variations pages?
  32. List all images from a single post meta value
  33. Populate Custom Fields in a Custom Post Type?
  34. Meta Key Value in current-user-only loop
  35. How to check if user meta field is empty in conditional else statement
  36. How to implement a Google map store locator
  37. changing meta value and meta key of price field
  38. Posting to a Custom Post Type from front end – user generated content
  39. Update Post Meta for a logged in user
  40. A better way to add a meta box to custom post types
  41. Two Custom Post Types Many to Many Relationship
  42. get_post_meta not working on publishing
  43. How do I set all of a particular post meta to a value within the custom post type I’m in?
  44. Update postmeta Parent when post_status child change
  45. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  46. Cannot save CPT meta box
  47. Importing Data from a Non-WordPress database, into WP
  48. don’t publish custom post type post if a meta data field isn’t valid
  49. Custom fields for custom post type
  50. Check if post with same meta value exists
  51. custom post data – how to
  52. Submitting Custom Post Types with custom fields from Front-end form
  53. How to customize work area / admin area in a custom post type without plugins?
  54. create custom meta box with default value
  55. How to display custom field value on page?
  56. delete_post_meta() for whole CPT / multiple posts?
  57. How to get specific post meta by title or id
  58. copy images from custom field to another custom field
  59. Display custom post type for specific user
  60. How to show custom field on specific custom post type posts only when filled
  61. Cannot obtain custom meta information
  62. How can I output WPAlchemy repeating fields meta values in my page template?
  63. How to call a post’s metadata in shortcode.php?
  64. Need to have an archive widget which organizes and displays a custom post type using a custom date field
  65. How to hide a custom field from admin?
  66. delete duplicate meta_value with same post_id
  67. Search CPT Title AND Meta
  68. updating one custom meta field only
  69. Add a class to post_class if more than one post shares same meta_value_num
  70. How to keep a record of changes to a custom field?
  71. Add a meta field to the list of results for a custom post type
  72. Empty meta-box returns publishdate if no value is set?
  73. Filter search posts by post meta?
  74. Use Gravity Forms and a Shopping Cart for output to Freshbooks for an Estimate [closed]
  75. How do I ensure that post_type and Taxonomy use the same slug?
  76. Custom fields for post or terms which don’t update on post update
  77. Custom Post Type meta data getting deleted on bulk editing taxonomies
  78. Custom Form / Search with Custom Post Type Data
  79. Adding a location field to buddypress activity
  80. Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
  81. wp_set_object_terms creates taxonomies but does not add custom posts to it
  82. Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
  83. How to keep custom post type related information
  84. How can I add a meta[] to my custom post type and search by term with the Rest API?
  85. Show posts from WP Custom Post Type selected from a field in a metabox
  86. How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
  87. Creating an archive page or simple template to list all values of a custom field of specific post type listing
  88. Where is get_post_meta value located?
  89. Custom meta fields not showing up in WP_Response Object via custom endpoint
  90. Select Menu for Custom post Type does not save
  91. Advanced search form with filters for custom taxonomies and custom fields
  92. How can i display on front page a movie that is atached in a post type
  93. Querying meta values within an array
  94. Exposing custom fields to the user in custom type post
  95. Display a list of posts whose meta field values are equal to the ID of the post being viewed?
  96. Check for custom field value in different post type than current one and do something
  97. Creating post custom field text area
  98. Sort CPT by taxonomy AND THEN by custom field
  99. How to display *block number* instead *date value* on WordPress posts?
  100. Where can I find the missing page sections in wordpress?
Categories custom-post-types Tags custom-field, custom-post-types, customization, post-meta
Landing function through URL
Templating advice sub posts of a CTP

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