When using LIKE
clause, you should be using %
to the start and end of the value to make it match with the existing values. So your query should look like this.
add_action( 'pre_get_posts' , 'my_pre_get_posts' );
function my_pre_get_posts( $query ) {
$value="%".$_GET['s'].'%';
if( $query->is_main_query() && $query->is_search() ) {
$query->set(
'meta_query',
array(
array(
'key' => 'pdf_content',
'value' => $value,
'compare' => 'LIKE'
)
)
);
}
}
Related Posts:
- Using meta_query on pre_get_posts to exclude a particular meta_key value
- pre_get_posts and set
- WordPress Screwing Up ‘orderby’ => ‘meta_value_num’ in ‘pre_get_posts’
- Can I use pre_get_posts to add up values from two different meta_keys?
- meta_query Array
- Order resultset by configured value and then list all the rest
- Why does this incorrect pre_get_posts meta_query work for sort order?
- How to do a meta query using REST-API in WordPress 4.7+?
- Get result from meta_query() between two numbers
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Archives for custom post type based on a “date” meta value
- get_users meta_query
- Meta query interfering with orderby relevance
- meta_query with multiple values
- Return posts with specific meta key first, but the rest in alpha order by last name
- meta_query key value from array
- filter search result with custom post type meta key
- Order by nested named meta queries with ‘exists’ and ‘not exists’
- Arrange Posts By Date In Order Of Closest To The Current Date
- Using get_terms() with meta_query parameters
- WP_User_Query with meta_query array relation ‘OR’
- Can’t sort order of wp_query with 2 meta keys
- meta_query problem
- Custom Upcoming Events List for Events Manager Plugin
- Using meta_query and custom fields within pre_get_posts to return posts within a numerical range
- How to exlude posts that have certain meta_value?
- User Relationship
- WordPress Core – Optimizing meta_query generated SQL?
- Edit post_content on posts with Featured Image
- Display no post when metavalue is 0
- Use both meta query and tax query
- meta_query, number comparison, not quite working as it should
- Meta Query Compare with Date
- pre_get_posts order by not working
- Does meta_query working with value paramater higher then 999?
- Single meta_query query using OR instead of AND in request’s WHERE statement
- meta_query keys and sticky posts
- Using meta_query with multiple keys and compare values
- Fastest way to do meta query when I don’t need the actual posts, and just need post_id?
- How to query post only with different excerpt?
- Order ascending is ignored in meta query?
- WP User Query Issues
- How to use meta query for greater than value in array?
- Wp Query custom search by meta query
- Filter posts by meta query?
- Help on multiple meta_query
- Meta query date column add [x] days to validate
- How to use orderby with meta_query?
- Orderby doesn’t work like expected on custom query
- I would like to have add_post_meta to return the ID instead of true or false
- last_name + first_name orderby with meta_query [solved]
- how to get post meta where value is an array of key value pairs
- Meta Query Based on Month Range
- Find posts by related taxonomy field
- wordpress meta value compare between two date
- Unpublish Authors With not Fulfilled Fields
- WP JSON API meta_query not working
- get_users with Serialized Custom Meta Value
- Sorting posts by ACF field
- Ordering custom posts by meta field date
- latitude/longitude meta_query
- meta_query displays all results and none, my query is wrong
- How to properly escape values in meta query
- Delete all posts with a specific custom field using meta_query
- Fetch custom post related to a User
- Use meta_query in args for relationship
- meta_query compare “=“ returns nothing when it seems it should
- Issue with user meta_query
- Woocommerce products search with custom fields
- How to get an archive page meta?
- Search for value(s) in meta field for a multi select
- Querying terms with calculations based on term meta data, sql vs. get_terms
- How can I create a meta_query with an array of dates?
- How to count items of meta query?
- WordPress meta query with meta serialized data array value
- wordpress meta query with multiple meta condition causing a load on server and slows down the server..!
- Trouble with calling an imploded variable in an array
- Memory Leak in Processing Large JSON file
- Meta Query returning empty array
- Exclude Posts Using Meta Query and User Meta
- meta_query not filering but meta_key works fine
- get posts meta query returning the latest post if no meta key found
- WordPress search between two newmeric values with a custom post type
- like_escape notice when using LIKE in meta query
- Display query post based on two orderby value in wordpress
- WP User Query with meta queries
- WP_Query with UNIX timestamp in meta query
- Querying by meta key and value
- How to compare date in post meta value
- Sort posts by post views and consider meta key
- Sort posts in dashboard using custom field; also include posts where field isn’t set
- Meta query “OR” comparison not working as expected with array
- Looking for a way to exclude frontpage and nav menu from query filter
- Get_term with meta_query
- WordPress Meta Query very slow with NOT EXISTS comparison
- ACF meta_query field treated as “0” resulting in false negative search when testing ranges
- Is it possible to customize meta query in this way?
- Ordering WP_Query results by second meta_key
- How making a new search box in admin post table working on a specific column
- wp_user_query with meta_value_num for leaderboard