… 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
- Query custom fields with three dates – start and end does not work
- Using meta_query, how can i filter by a custom field and order by another one?
- Mixing regular and custom post types (with meta_query) on home page
- meta_query for keys that aren’t yet set
- Fail to compare dates in meta_query
- Get posts based on meta key/value
- How to create a wp_query that contains both meta_query and tax_query
- 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)
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- How Can I save multiple records in same meta key?
- modify all posts of a category to “no comments allowed”
- Order Posts by Taxonomy and Meta Value
- 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
- order by meta_value serialized array
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Using Query Posts With Multiple Post Types And A Taxonomy
- Create Pages from Database
- 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
- query order by date on custom type: wrong order
- Used with meta_query in query_posts works slowly
- exclude custom post type by meta key in wp_query
- 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
- Display custom post types with custom date field value (before today) & order by custom date field
- Query to change custom post type with specific category
- Displaying Metabox value (custom post type taxonomy)
- Query for custom post type objects in a taxonomy and with a meta value
- Display custom post type taxonomy and month
- Mass convert MySQL data entries into custom post type?
- Calculating Bayesian average for custom post type
- Meta_query with relation ‘OR’ killing server CPU
- CPT Meta Searching
- Filtering by Post Meta Custom Fields – Performance
- Ignore sticky posts if post is not in meta query
- Is it possible to apply a meta_query to one specific post type in a query with multilple post types?
- Query that joins the postmeta table twice
- meta_query compare >= not working but
- Deleting Custom Post type data using mySQL command
- advanced search forms with 3 input text and that the main problem 3 input text
- wpdb custom post_type problem
- Adding custom tables to WordPress
- $wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies
- Pull a post based on a meta value in a custom post type
- Setting proper query for multiple custom admin filters
- WP_Query: include custom post type only with specific meta value
- 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?
- Convert simple SQL Query to WordPress query
- wp_query check if integer exists in custom field’s array
- Filtering custom post type on a combination of custom taxonomies and custom fields?
- Get posts between custom dates
- filter custom post type by meta key in dashboard
- Meta query for custom post type ignored in main query
- 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
- Why is this query not working? (Standard posts + custom post type)
- Using meta_query and tax_query at the same time
- Assign External Database Queries to Global Variables and Make Them Accessible
- How to import a custom MySQL DB table into a WordPress custom post type
- search suggest – filter post type
- Function causing the loop display posting more (empty)
- Meta Query posts not showing on ending date of custom field
- Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Ordering custom post type by multiple custom fields
- How to Output which matched meta_keys were found from custom_type_posts?
- Possible to filter custom post type with multiple meta data?
- wp_insert_post sometimes fails after API call
- filter search custom field query
- 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?
- Front end access to a SQL data repository – recommended way?
- Navigate posts with different post type that are in the same categories
- WP_query – Filter by tax_query and meta_query using multiple select
- Is it possible to load a different sidebar in single.php based on a meta_query filter?
- Getting a custom post’s custom field based on another custom post’s custom field select
- Querying multiple values from a single key
- find custom post type post by searching its custom field with my string
- Update post if exist from PHP