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

Get all the posts where meta field with multiple choice has several values checked

did you try to call like this:

$args = array(
  'post_type'  => 'product',
  'meta_query' => array(
    'relation' => 'OR',
    array(
        'key'     => 'spec',
        'value'   => 'choice2',
        'compare' => 'LIKE',
    ),
    array(
        'key'     => 'spec',
        'value'   => 'choice3',
        'compare' => 'LIKE',
    ),
  ),
);
$query = new WP_Query( $args );

example taken straigh from the codex

Related Posts:

  1. Copying Custom Meta Values from existing post to a duplicate post
  2. Unable to show ACF’s Image Custom Field properly in Genesis Framework [closed]
  3. ACF: How to get the full field name (meta_key) by a field key?
  4. WordPress creates new lines in postmeta table on post update
  5. How to get custom image field of specific post id
  6. Query Posts based on custom field value
  7. save all acf options in one meta_value [closed]
  8. Advanced Custom Fields: how do I check to see if a value is set in an field? [closed]
  9. Can I exclude a post by meta key using pre_get_posts function?
  10. Where are custom field values stored in the database
  11. Custom post meta field effect on the performance on the post
  12. How to get custom post meta using REST API
  13. Difference between meta keys with _ and without _ [duplicate]
  14. Orderby meta_value only returns posts that have existing meta_key
  15. What is the index [0] for on post meta fields?
  16. What is “meta_input” parameter in wp_insert_post() used for?
  17. How to enable revisions for post meta data?
  18. The “_encloseme” Meta-Key Conundrum
  19. Best way to programmatically remove a category/term from a post
  20. Using get_post_meta with new_to_publish
  21. Advanced Custom Fields – Get custom fields from parent page
  22. Add custom field to the archive page?
  23. Matching Serialized Arrays with meta_query
  24. Custom field metabox not showing in back-end
  25. So much data in postmeta
  26. Can I count the number of users matching a value in a multiple value key?
  27. How to position a custom field before the editor
  28. When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
  29. How to hide meta box values from custom fields list?
  30. Auto sort the wp-admin post list by a meta key
  31. get_post_meta() unserialize issue – returns boolean(false)
  32. Display post_object content using Advanced Custom Fields plugin
  33. What is the advantage of the wp_options design pattern?
  34. Remove old custom field after import
  35. Storing meta fields multiple times OR once with multi dimensional array?
  36. Unable to get Preview of Uploaded image within a Custom Meta box
  37. Allow user to create instances of custom field
  38. display specific custom fields
  39. Is there a hook / action that is triggered when adding or removing a post thumbnail?
  40. Meta keywords and descriptions plugin for manually editing meta for each page/post
  41. Retrieve custom fields on Categories, using WP-API
  42. passing argument to get_template_part() or a better way to code
  43. Is it possible to store arrays in a custom field?
  44. Get updated meta data after save_post hook
  45. Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
  46. Save HTML formatted data to post meta using add_post_meta()
  47. importing data from non-wordpress mysql db
  48. Order by custom field date?
  49. Create meta boxes that don’t show in custom fields
  50. Transients vs CRON +Custom Fields: Caching Data Per Post
  51. Unable to save datetime custom meta field using update_post_meta() function
  52. Up/Down voting system for WordPress
  53. Change content before writing to database
  54. post meta data clearing on autosave
  55. Create custom field on post draft or publish?
  56. Display info from custom fields in all images’ HTML
  57. Order Custom post type loop by custom field (datepicker)
  58. Ordering posts by anniversary using only day and month
  59. get_post_meta fields don’t show up on posts page
  60. Using Custom Function With Advanced Custom Fields
  61. Update meta values with AJAX
  62. How to break meta values into different items and avoid duplicates?
  63. automatically set “Featured Image” the same as the og:i that is set in a custom field
  64. copy attachments to another post type and change attachment url
  65. Cannot edit post meta fields with rest API
  66. ajax delete value from custom field array
  67. Problem with adding exta field in metabox in custom post type
  68. Save attachment custom fields on front end
  69. How to use pagination with get_post_meta
  70. Add a post meta key and value only if it does not exist on the post
  71. Move value of one custom field to another
  72. Order posts according to user defined order for meta values?
  73. Calculate the sum of certain the_sub_fields
  74. Displaying posts with only upcoming dates according their custom field date value
  75. Displaying Custom Fields on Post with Genesis Child Theme
  76. Custom fields to save multiple values
  77. Custom fields: In what order are they saved into the DB?
  78. Function to change meta value in database for each post
  79. ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
  80. Get a post_id where meta_value equals something in a serialized meta_value field
  81. Get aggregate list of all custom fields for entire blog
  82. Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta
  83. Login & Register & Custom details WITHOUT plugin
  84. Custom field value based on other custom field values
  85. Send Multiple Custom Field Values Through the URL
  86. wp_handle_upload error “Specified file failed upload test” but still creates attachment?
  87. ACF won’t load from a custom JSON location
  88. How to save a ToggleControl value in a meta field?
  89. Which is best in the following scenario : post_meta vs custom table vs parent/child posts
  90. Saving custom image meta fields
  91. Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
  92. How to display Meta Field Value?
  93. MySQL query to set wp_postmeta using term_taxonomy_id value
  94. How to Validate Post Meta type/extension (Video File Image File etc)
  95. Get all meta keys assigned to a post type
  96. Show ACF fields only on certain page in the backend
  97. using multiple meta_key and meta_value in query_posts
  98. Update posts after populating ACF field value [closed]
  99. Custom Meta Box not Saving in Posts with Gutenberg Editor
  100. How can I pass a variable set by ACF to header.php?
Categories custom-field Tags advanced-custom-fields, custom-field, post-meta
PHP error when trying to upload .mp3 files via Media Library [closed]
How can I count only guests comments?

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