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 by mime type not working in pre_get_posts
  25. search filter for search and tag page doesn’t work
  26. Consistent and Admissible Heuristics
  27. Solr vs. ElasticSearch
  28. How do you make Vim unhighlight what you searched for?
  29. grep for special characters in Unix
  30. Search is always exact [closed]
  31. Can I exclude a post by meta key using pre_get_posts function?
  32. Advanced search form with filters for custom taxonomies and custom fields
  33. how to limit search to post titles?
  34. How to create live autofill search?
  35. How can I implement a location based (zip code) search in WordPress?
  36. How to highlight search terms without plugin
  37. How do I remove Pages from search?
  38. Empty search returns home page, how to return not found search page?
  39. How to search for (partial match) display names of WordPress users?
  40. How does WordPress search work behind the scenes?
  41. Remove some pages from search
  42. Limit search to latin characters
  43. How to look at code in WordPress repositories without downloading?
  44. Extend WordPress search to include user search
  45. Display search results within the same page
  46. Empty search input returns all posts
  47. How can i move search results onto a specific page?
  48. Using pre_get_posts to rewrite search query to display posts from multiple taxonomies
  49. Remove meta robots tag from wp_head
  50. WordPress blog with 30 000 posts: poor search performance
  51. Custom search filter causes menu and query_posts problems
  52. Template issues getting ajax search results
  53. WordPress database error: [Not unique table/alias: ‘wp_postmeta’]
  54. Insert DIV container below 1st search result
  55. Unified search across separate WordPress installations
  56. Search in WordPress – Difference of searchpage.php, searchform.php and search.php?
  57. How to make WordPress search prioritise page titles?
  58. Reduce or prevent calling of update_meta_cache
  59. How to add the author search in the default wordpress search?
  60. Admin Area Custom Type Search By Meta Fields Without Title & Content
  61. How do I filter the search results order?
  62. How to insert a span inside a search form?
  63. How do I redirect /search/ to wordpress search template?
  64. How do I Paginate Search Results for Custom Post Types?
  65. Dealing with Many Meta Values, 30+
  66. How to search for users based on added user metadata
  67. Search by Post ID and display content of the post in search result
  68. Extending search query with additional $sentence value
  69. Link to search page without search parameter
  70. Order Search Results Page by meta_value If no Value Return Remaining Results
  71. Search/Replace for editor in HTML-mode
  72. How do I search events between two set dates inside WP?
  73. Search only blog posts (default WP search widget)
  74. Exclude pages from WordPress search result page
  75. How to pass a search $_GET parameter to a new custom search page?
  76. Do I need to sanitize WordPress search query?
  77. Disable Redirect to Product Page on Search Results Page in WooCommerce [closed]
  78. Search Using Post ID
  79. Search custom post type by meta data
  80. Neither the_excerpt() nor the_content() works properly?
  81. Let user change posts per page
  82. Search ONLY by meta key / meta values
  83. WP User Query with search columns and meta query
  84. Exclude top-level pages from search results
  85. WordPress 3.6, searchform.php problems
  86. Search in non-English language returns only one result
  87. Complex Search functionality. Advice needed
  88. Get user role by using user_id in buddypress
  89. How to use next_post_link and previous_post_link on single posts in search results
  90. Why is there a class=”screen-reader-text” on my search button?
  91. template_include for search.php makes WordPress think its on the home page
  92. Turning Broken URLs Into Search Terms?
  93. How can I implement faceted search with WordPress 3.x?
  94. can’t limit search to only pages
  95. Meta query interfering with orderby relevance
  96. Add custom field (value) to search result (without plugin)
  97. Add custom parameters to JSON API search query?
  98. Combining Meta_Query key values for one array
  99. Change the Search Base in a multi language wordpress
  100. Display posts from an author using search parameters (not author template/query_posts)
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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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