… I will need to be more specific, by adding a “%” after $author
(James). The problem is that this will not work at all. Any idea why?
The %
is a wildcard with a MySQL LIKE
query, which I suspect you know. With meta queries, WordPress will add one to the beginning and one to the end of the string you provide. You can see that in the source. or just by var_dump
ing the query. By adding a %
of your own, I suspect is throwing things off. By the time WP_Query
and wpdb
is through with it, it ends up looking like \\%%
. I just ran a query through to check that.
Unfortunately the LIKE
meta_query is not very flexible, but maybe you could sort it out with the get_meta_sql
filter.
Related Posts:
- Combine tax_query and meta_query in WP_Query
- Using meta_query, how can i filter by a custom field and order by another one?
- WP_Query() show posts that end later than today
- WP_Query orderby custom field then post_date in one query
- Filtering a WP_Query meta_query by numeric values isn’t working
- Ordering posts having multiple post-meta date fields
- Querying custom post type with 2 custom fields (date-range)
- How Can I save multiple records in same meta key?
- Ordering Post 2 Post admin meta box by meta from CPT
- filter search result with custom post type meta key
- I can’t set meta_key in my custom post type query
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Using Query Posts With Multiple Post Types And A Taxonomy
- How do I write this SQL statement for Posts written in last 24 hours?
- Can’t sort order of wp_query with 2 meta keys
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- How loop through posts based on custom fields
- Custom query variable – get wordpress to redirect to nice permalink url
- Filter posts with meta_query NOT IN where value has multiple values
- Query to change custom post type with specific category
- Displaying Metabox value (custom post type taxonomy)
- Display custom post type taxonomy and month
- Mass convert MySQL data entries into custom post type?
- CPT Meta Searching
- Filtering by Post Meta Custom Fields – Performance
- Ignore sticky posts if post is not in meta query
- Query that joins the postmeta table twice
- advanced search forms with 3 input text and that the main problem 3 input text
- Adding custom tables to WordPress
- Setting proper query for multiple custom admin filters
- Sorting Custom Post Type by Meta Value but wont display when set to 0
- Insert post metadata for all posts in CPT at once if metadata no existent
- How to alter WP-JSON main query or best practise for custom endpoints
- Returning a list of custom post types excluding those without a specific meta_value
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- wp_query check if integer exists in custom field’s array
- Get posts between custom dates
- filter custom post type by meta key in dashboard
- How to filter wp_list_categories output with some custom post type meta query?
- Display a CPT based on a metabox selection
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How to do WP_Query with two meta fields with orderby clause
- Stuck in Order by more then one
- Meta Query Not Returning Output Despite Having Matching Values
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- WP Meta query for a custom post type based on two values
- Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
- Ordering custom post type by multiple custom fields
- How to Output which matched meta_keys were found from custom_type_posts?
- How to let users choose where to search for posts?
- Query based on custom fields start and end date
- Proper way to display latest 5 posts grouped by post type?
- Getting a custom post’s custom field based on another custom post’s custom field select
- Get category if used in a custom post type
- Custom Query: If One Post Object Field Value Is The Same As Another
- If meta_value of meta_key is less than today’s date update meta key
- I’m trying to create a custom version of the wp_list_authors function that includes custom post types
- Query Posts, order by meta value
- WordPress giving a 404 page when passing a year argument different than the current year
- Two queries – one with checkbox ticked, one without – comparing meta_query
- How to import database table as custom post type and custom fields?
- $wpdb is queried but results don’t show
- SQL query – get ids – Advanced Custom Fields / WPeC
- Why doesnt my tag page populate with this custom post type?
- Dynamic template page calling shared taxonomies CPT or Plugin post type : how to clone taxonomy for plugin + set up dynamic shortcode
- Filter result of Custom Post Type using meta_query with ACF
- Query posts by current ACF meta key value on single page as related posts
- meta_query Where the key value is stored as an array
- Orderby if between two meta fields
- How to select meta key in custom database query
- Use WP_query to match post types based on custom field values
- ACF meta_key and meta_value break loop
- Why is this function so slow?
- Sort custom post archives by a meta value from a different custom post type?
- How to get the posts that my following users are liked?
- Meta_Query refuses to return results
- Sort loop by custom field from different post type
- Meta_query by date for Events archive
- How to shows CPT which has specific meta key?
- Query events post type after current date and timezone
- Conditional posts in WP_query for search
- Custom post order when using OR relation
- meta query always fails even if data is correct
- shortcode order for event custom post type
- Events with multiple event dates + permalink for each date
- Unable to get the upcoming events for custom post
- Filter RSS feed for custom post type to events for next 7 days only
- Trying to combine multiple WordPress queries
- Ordering by multiple meta keys – Custom post type
- Problem with a query in custom posts
- WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
- Querying meta values within an array
- Create a WordPress Database query to find users who purchased specific product through WooCommerce [closed]
- Check for custom field value in different post type than current one and do something
- Function to Compare CPT Post Custom Value with Default Posts CF Value
- WP_Query() displaying past post / event
- WP Query Conditionally query meta and taxonomy
- Assign a tag to custom post type using a query
- Meta_query question