First of all – I assume the $search variable is being populated from $_GET (it’s not in your code).
Secondly, do you need the % ? I think using LIKE with wp_query doesn’t require them.
Related Posts:
- Use REGEXP in WP_Query meta_query key
- Getting attachments by meta value
- What is an efficient way to query based on post_meta?
- WP_Query not working as expected for attachments and custom meta_query
- How can I create a WP_Query that returns posts where one meta_value
- WordPress altering my custom query, How to fix it?
- WP Meta Query for some meta (array) values
- How to get sum of meta_values of a meta_key in wp_query according to conditions
- Order posts by meta value and Date
- Get meta info related to current post
- How to make Meta Query case sensitive?
- Performance when getting post meta for post retrieved by meta value
- Get attachment by meta_key value
- Fetch Record based on meta key dates
- how to make members list directory through wordpress post custom meta key.
- Large AND OR query timing out
- Filter posts by comparing custom meta value against postdate
- Nested array issue in meta_query
- WP_Query meta compare must include ALL array values
- How do i create a custom post query when the meta value is an array?
- wp query to use both author id and meta_query
- Meta query ignores multiple values of the key
- Trouble with serialized metadata
- show most viewed post
- Why can my filter query SOME metadata but not other metadata?
- Query against multiple locations within single custom post type post
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- Saving custom fields for WP_Query to retrieve
- How to show all the associated posts with specific date of data metabox?
- WP Meta Query at depth 2
- WP_Query Posts by Metadata from Option Tree
- Return a single custom post from multiple meta queries
- WP_Query by meta key not returning any posts
- Meta_query compare operator explanation
- meta_query with meta values as serialize arrays
- How to only display posts whose meta_value field is not empty?
- Nested meta_query with multiple relation keys
- Can wp_query return posts meta in a single request?
- order by numeric value for meta value
- meta_query ‘compare’ => ‘IN’ not working
- How do I query for posts by partial meta key?
- WP Query Args – Title or Meta Value
- Meta query with string starting like pattern
- compare meta_query in get_posts arguments
- WordPress retrieving meta data for all custom post types in list view
- How to query posts based on lat-lng coordinate as post meta?
- how to show posts that are missing a meta_value
- Order by optional meta key?
- Set Alias for meta_query arguments in get_posts()
- Sorting: custom query with orderby meta_value_num THEN by title
- meta_query: using BETWEEN with floats and/or casting to DECIMAL
- Display products from specific category in shop page
- Reduce or prevent calling of update_meta_cache
- Is there a way to extend WP_query so Custom Post Types can have properties?
- How to Compare Two Meta Fields
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Does tax_query really beats meta_query in all situations?
- WP_Query with checkbox meta_query
- ACF Relationship Field Search Filtering [closed]
- What is the most efficient way of querying posts based on visits and date for current day?
- Add indexing to meta_value in wp_postmeta
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Custom WP_Query order by post_meta and (author) user_meta
- Query WooCommerce orders where meta data does not exist
- Query Multiple Post types each with own meta query
- WP_Query displaying ALL posts
- Execute a large WP_Query with many “AND” Meta_Queries?
- Query all posts where meta value is empty
- meta_query where value is equal to given value
- WP_Query min and max values
- Query Custom Meta Value with Increment
- WP-CLI How to generate a list of posts with corresponding meta values
- ACF datepicker meta_query Compare Dates in m/d/Y g:i a – Not in Ymd Format
- WP_Query using meta_query with relation OR and orderby meta_value doesn’t work
- Using custom meta_query with relation not working as expected
- Perform query with meta_value date
- querying with custom meta field with meta_query
- Order by two meta keys
- multiple meta key but get server load is very high
- Meta Query with date and time on the same Day before given time
- A WP_Query that will look for posts after 2 weeks ago OR with a certain meta value
- How to grab metabox value in wp_query meta_query key
- WP_Query meta_query where meta value ends in space
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- Nested query inside Logical operator OR not working in meta_query
- Is “orderby” in WP Meta Query conflicting with Meta Query?
- Query by meta_key and order by meta_value_num return orderby date
- datetime picker, timestamps and meta queries
- How do I create my own nested meta_query using posts_where / posts_join?
- How to count post meta key values for all posts in database
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Group posts by meta_key
- How should I use posts_where to change meta_value from a string to integer?
- Compare two meta-fields in a wp_query (where meta-field-A is larger than meta-field-B)
- Wp_query order by multiple custom fields?
- Meta Query querrying several post types based on ACF fields is broken after update to WP 4.1
- Comparisson between date() and a date from wp_postmeta
- Can’t sort order of wp_query with 2 meta keys