please never do this: 'value' => $_GET['s']
… $query->get('s');
, get_search_query, or sanitize_key($_GET['s'])
are all safer options. Technically we shouldn’t be using get-params in wordpress at all, it’s not a best-practice. That get value could be all sorts of bad things, & we don’t want to pass it along to the db without making sure it’s clean.
Also, you’re using the LIKE
operator… so you might want to add quotes around the value for stricter matching.
'value' => '"'.$query->get('s').'"';
Related Posts:
- Using meta query (‘meta_query’) with a search query (‘s’)
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- Is there a way to do multiple ordering on a multiple meta_query?
- WordPress Search Custom Meta Field Only
- How make a custom search on backend in WordPress without plugin?
- How do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?
- Meta Query And/Or
- filter custom field values $min $max
- Need to search a custom field (ingredients, one long string per post), but want it to allow phrases/non-exact matches
- searching by keywords in post’s metas or pagination links problem
- Create custom query for search?
- SQL query based on two different custom field values
- ORDER BY custom field value
- SQL Query to copy value of a meta_key into another meta_key
- How to correctly call custom field dates into a posts_where filter using SQL statements
- Can I query custom meta data through WP_Query
- Including custom fields in search?
- How to rename a custom field?
- Matching Serialized Arrays with meta_query
- Meta Query with AND & OR?
- Custom search: by post data and post metadata?
- Need small coding with Custom Fields Search
- Search ONLY by meta key / meta values
- Filter results with custom field values and dropdown
- Add custom field (value) to search result (without plugin)
- Trying to perform complex custom field query with order by set to field value
- searching in custom meta field
- Bulk move (or copy) from a custom field to the post content?
- Up/Down voting system for WordPress
- Custom Fields Bulk Edit
- Compare meta_query decimals not working right
- Ordering posts by anniversary using only day and month
- Calling Specific Pages with wp query Part II
- Loop through two different sets of custom fields
- Exclude custom post type from search by custom field value?
- Slow meta query with multi meta keys
- Using OR in WP_Query negates the “NOT EXISTS” compare
- How can I query on the year part of a complete date in a custom field?
- How can I combine meta_query queries?
- Displaying posts with only upcoming dates according their custom field date value
- Difference between ‘LIKE’ and ‘IN’ in meta queries
- Sorting posts by multiple values, combined
- meta_value_num sort glitch
- WP_Query display next custom post from today’s date
- Extend ‘The Events Calendar’ search to include custom fields [closed]
- Include woocommerce custom field value in front-end search result
- Which is best in the following scenario : post_meta vs custom table vs parent/child posts
- WP_Meta_Query causing long-running MySQL queries
- Including Database Generated Pages in Site Search [closed]
- Sorting posts by custom fields in meta_query
- meta_query for a string inside a meta field containing a comma-separated list
- Order by custom field value not working for acf date field
- Adding Custom Fields to Search
- sort search results by custom fields using dropdown
- Get all posts that do not have a specific custom field without using a subquery
- Using a checklist to search against metadata
- Complex WP_User_Query call fails on production server
- How do I use wp_query for WordPress search?
- Meta query with timestamp using WP_query
- Custom Fields Not in Search Results
- Orderby custom field meta value ASC and then by date DESC
- Order query by meta_value with multiple custom fields
- Custom Field Create Bulk via SQL Query
- filtering custom post types via meta data drop down
- How to add a new meta key and assign timestamp to posts
- Get content from pages with same meta_key from Database
- WP 3.1 meta_query for multiple custom field values
- Advanced search by two criteria – sort by location and date (ascending or descending)
- Including metaboxes from custom post types in global search — continued
- Extend product search with meta in WooCommerce
- Advanced search for meta fields
- Get posts with same meta value as current post
- Merge Multiple Custom Fields into one New Custom Field for Searching
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- Alter main archive, to show posts with meta as last
- Meta Query returns wrong number of posts
- How to populate custom field dropdown box based on prior selection?
- Search in Archive Pages by subcategory, tag, custom field and year
- Custom WP_Query for WordPress Search Results with meta_query
- Change order of posts
- Use meta_query to get title of associated post
- Meta query with multiple custom fields for archives page ordering problem
- filter search custom field query
- How to let users choose where to search for posts?
- Restrict WordPress Search to Custom Field
- How can you include custom post meta in search without calling each key?
- Ordering posts by custom field named “date” in backend
- Get Data From wp_sitemeta for Multisite network
- Unique meta_key with array value vs repeated meta_key with single values
- get posts where a custom field contains a text
- WP Query – Is this correct?
- How can I do a variable for meta_query?
- Avoiding ACF get_field and returning to core WordPress function
- ORDER BY custom field value out of where clause
- comment meta_query for keys that aren’t yet set
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- change order of images attached to post
- Meta_query ‘compare’ => ‘LIKE’ not working?
- Diamond question mark in text after migrating content