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 do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?

I had the same desire. A quick and dirty answer is to use the get_meta_sql to replace the leading 'AND' with an 'OR'.

(See also the answer here: https://stackoverflow.com/questions/43734845/how-to-give-or-relation-in-tax-query-and-meta-query-wordpress ( A related, but not duplicate, question.) )

Related Posts:

  1. Using meta query (‘meta_query’) with a search query (‘s’)
  2. Add custom fields to search
  3. Is there a way to do multiple ordering on a multiple meta_query?
  4. WordPress Search Custom Meta Field Only
  5. Ordering posts by anniversary using only day and month
  6. Displaying posts with only upcoming dates according their custom field date value
  7. Which is best in the following scenario : post_meta vs custom table vs parent/child posts
  8. How do I use wp_query for WordPress search?
  9. How make a custom search on backend in WordPress without plugin?
  10. filtering custom post types via meta data drop down
  11. How to add a new meta key and assign timestamp to posts
  12. Custom WP_Query for WordPress Search Results with meta_query
  13. filter custom field values $min $max
  14. How can you include custom post meta in search without calling each key?
  15. Ordering posts by custom field named “date” in backend
  16. Unique meta_key with array value vs repeated meta_key with single values
  17. Avoiding ACF get_field and returning to core WordPress function
  18. change order of images attached to post
  19. Need to search a custom field (ingredients, one long string per post), but want it to allow phrases/non-exact matches
  20. How to improve my non-unique metadata MySQL entries?
  21. searching by keywords in post’s metas or pagination links problem
  22. Search one custom field?
  23. Create custom query for search?
  24. Query postmeta values, and return multiple post_titles for common meta value
  25. WP Query Args – search by meta_key or title
  26. Search for meta_query does not return any result if combined with title
  27. Advanced search form with filters for custom taxonomies and custom fields
  28. Custom post meta field effect on the performance on the post
  29. Difference between meta keys with _ and without _ [duplicate]
  30. Orderby meta_value only returns posts that have existing meta_key
  31. What is “meta_input” parameter in wp_insert_post() used for?
  32. How to enable revisions for post meta data?
  33. Can I query custom meta data through WP_Query
  34. Including custom fields in search?
  35. Is there a hook / action that is triggered when adding or removing a post thumbnail?
  36. Filter results with custom field values and dropdown
  37. passing argument to get_template_part() or a better way to code
  38. searching in custom meta field
  39. Create meta boxes that don’t show in custom fields
  40. Calling Specific Pages with wp query Part II
  41. How to use pagination with get_post_meta
  42. Copying Custom Meta Values from existing post to a duplicate post
  43. Move value of one custom field to another
  44. Custom fields: In what order are they saved into the DB?
  45. Get a post_id where meta_value equals something in a serialized meta_value field
  46. How to save a ToggleControl value in a meta field?
  47. Including Database Generated Pages in Site Search [closed]
  48. Order by custom field value not working for acf date field
  49. How to Validate Post Meta type/extension (Video File Image File etc)
  50. Adding Custom Fields to Search
  51. How can I sort homepage by a meta value?
  52. Meta query with timestamp using WP_query
  53. How to wrap meta values seperated by comma in ? [closed]
  54. Create Multiple File Upload Metabox in WordPress
  55. Hide custom meta data if empty
  56. Extend product search with meta in WooCommerce
  57. how to make members list directory through wordpress post custom meta key.
  58. Advanced search for meta fields
  59. Get posts with same meta value as current post
  60. Add custom field to all posts in specific post_type
  61. How to populate custom field dropdown box based on prior selection?
  62. Can I access a post meta field before the loop?
  63. wrap text around custom fields array
  64. How can I modify RSS item titles to be either the title or a custom meta field?
  65. ORDER BY custom field value out of where clause
  66. Get all the posts where meta field with multiple choice has several values checked
  67. Move Title and the Content WYSIWYG editor position
  68. How do i get the attached images with custom value checked?
  69. ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
  70. Diamond question mark in text after migrating content
  71. Get custom fields without _edit_last, _edit_lock, _wp_page_template and _visual-subtitle
  72. Include one custom field in search results
  73. Display posts with empty custom field
  74. Custom search SQL Query to add custom field in result
  75. Search Results Page – Displaying Custom Meta Fields
  76. Search CPT Title AND Meta
  77. Custom field Search with Relavanssi
  78. How to exclude custom fields from search queries?
  79. Footnotes in custom fields
  80. Create a new custom field for all posts based on current custom field
  81. wordpress get_post_meta / the_meta to output custom field value
  82. How to show content of custom fields in search results?
  83. Custom Query: query by post custom meta data
  84. Search & column order by meta value in admin
  85. Set class if a meta value is set within post archive
  86. Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
  87. Filtering posts by ACF meta query
  88. Can’t set custom meta fields for a post
  89. Very large list of options for BuddyPress profile fields
  90. Allow HTML in Custom Metabox area
  91. Custom field metabox not showing in back-end
  92. Search fails when using the radio buttons
  93. Query Multiple meta
  94. When post is updated, custom metadata in text area field is overwritten
  95. Media Attachment Custom Meta Fields not saving in Media Uploader when using jQuery UI Autocomplete
  96. Custom Field: Display only if a specific key is selected outside the loop
  97. When editing a post with a custom meta box the values aren’t displaying correctly
  98. add_post_meta insert null value into Database
  99. Extend search query to search meta keys values based on search string
  100. get Custom field label (select/dropdown) on front end
Categories custom-field Tags custom-field, meta-query, post-meta, search
Enable WordPress to share cookies between domain.com and sub.domain.com
How to Upload CSV Data into Custom Post Type Data with Metabox programmatically

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