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

meta field search too restrictive in pre_get_post() for custom search

Seems I have an answer – it was how the SQL statement was setup.

$where .= " OR (( $wpdb->postmeta.meta_key = '$meta_key' AND (UPPER($wpdb->postmeta.meta_value) LIKE '%$meta_value%') ))";

Now is the field has the string “Whistler Bike Park, Canada” but the user only searches for “Whistler”, I get the post/s returned that I expect.

Related Posts:

  1. How to make search include data from wp_postmeta?
  2. Create multiple Search functions for posts / custom post types and everything
  3. How Do I Use WP_Query to Run This Database Query as Search Result?
  4. pre_get_posts and search query for admin
  5. Custom search for custom post meta with pre_get_posts interferes with WP search
  6. Search function works improperly
  7. Searching by meta values showing inappropriate result
  8. Force is_search to always TRUE
  9. How to conditionally pass a parameter to wordpress search to limit post types?
  10. How to make search include data from wp_postmeta?
  11. How to exclude pages from WP search based on page title
  12. Modifying post content with the_post action hook
  13. why pre_get_posts works fine in post type archive, but not in search result list?
  14. Search for two strings in WP search
  15. Displaying number of search results for each post type
  16. How to query two meta fields and display results between them
  17. Use pre_get_posts to display search results by meta in specific order
  18. meta post search
  19. Search custom posts by meta key in admin
  20. pre_get_posts improperly searching revisions
  21. search for single meta_key with numeric array of meta values
  22. WP search in metadata post
  23. Search for meta_query does not return any result if combined with title
  24. search filter for search and tag page doesn’t work
  25. Solr vs. ElasticSearch
  26. Can I exclude a post by meta key using pre_get_posts function?
  27. Limit search to latin characters
  28. Display search results within the same page
  29. Search in WordPress – Difference of searchpage.php, searchform.php and search.php?
  30. How do I redirect /search/ to wordpress search template?
  31. Search ONLY by meta key / meta values
  32. Exclude top-level pages from search results
  33. Search in non-English language returns only one result
  34. How can I implement faceted search with WordPress 3.x?
  35. Meta query interfering with orderby relevance
  36. Change the Search Base in a multi language wordpress
  37. Search results URL without query string variables
  38. How to control WordPress Search Behavior?
  39. Get the selected term in a dropdown search
  40. Separating search results collectively by type
  41. Changing the search results destination URL
  42. Noindex, nofollow stuck on homepage
  43. Is_search not working on search results page
  44. Making a list of post tags in string
  45. Strange Search Queries in Apache Status
  46. WP_User_Query search with multiple search queries
  47. update default search function and get postmeta entries
  48. Need to do blank search.
  49. Is there a wordpress plugin enabling an autocomplete search box, then jump to page?
  50. Date_query problems
  51. Need to return a list based on Slug
  52. Using parent slug variable to display proper submenu not working properly
  53. Get Adjacent post by search query
  54. How to get started?
  55. How to reset usual $query on search page to push custom $wpdb query there?
  56. Search.php display results differently based on post type
  57. Improved WordPress search functionality and search form plugin
  58. Use wordpress search to display results within a post
  59. Sorting search results with custom dropdown
  60. how to search everything
  61. changing search result from only excerpt to full content
  62. Cannot pass ‘S’ parameter more than two letters
  63. Localization of WP theme
  64. How to have multiple instances of the same taxonomy in a search form
  65. WP + Google analytics = /search?
  66. Search result count not matching actual result
  67. How to search for post content and attached file names
  68. Searching for one letter returns extra empty post
  69. How to create a search form with multiple search fields
  70. Block internal search queries with pre_get_posts and regex rules
  71. Search Exact on WordPress – Relevannsi Solution Not Working
  72. REST API: Search products only in the names
  73. Bots using internal wordpress search
  74. Altering search results to handle a post meta field not working in current WordPress
  75. WordPress Search by tags
  76. WordPress search post using unicode
  77. Create search box on Archive Custom post type
  78. How to pass variable to get_search_form()?
  79. Why the search results are wrong in search posts form?
  80. Search isn’t displaying all results
  81. How to use regular page template for search results?
  82. Search only blog posts on blog page
  83. Auto search field without buttons, shows first result from search page
  84. Can I set up a search box that uses fields?
  85. How to Search Users on the Base of Latitude and Longitude in Users meta_key and meta_value
  86. Search.php Modification Needed
  87. Search taxonomy terms, not posts
  88. Re-order posts inside tax query
  89. I want to edit the search function
  90. Custom Search Query – include only custom fields and title
  91. How to display articles based on composed tag
  92. Search query with quotes
  93. Search Results with googlemaps
  94. Custom WordPress Excerpt within terms
  95. Need help to be able to searching by tag and title
  96. Ivory Search error
  97. How to Prevent ?keyword Parameter from Being Indexed and Stop Its Generation in WordPress?
  98. Search posts by meta key in admin and front
  99. Organizing media files (pdf) and searching based on the folders created
  100. Extending the search function to a specific meta field value in the admin posts table
Categories search Tags post-meta, pre-get-posts, search
Get first URL from custom field, download and set as featured image on post publish
Manual excerpt being ignored on custom post type

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