Afaik, there’s no relation
key for meta_query
. Use compare
instead and maybe also specify a type
to speed things up with skipping types that are out of scope.
EDIT
$args = array(
'post_type' => 'product',
'meta_query' => array(
// Used to set two meta keys IN RELATION TO EACH OTHER
'relation' => 'OR',
array(
'key' => 'color',
'value' => 'blue',
// Used to FILTER OUT/IN/LIKE THE VALUE NAME
'compare' => 'NOT LIKE'
),
array(
'key' => 'price',
'value' => array( 20, 100 ),
'type' => 'numeric',
'compare' => 'BETWEEN'
)
)
);
$query = new WP_Query( $args );
Related Posts:
- 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
- Ordering posts having multiple post-meta date fields
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- Order Posts by Taxonomy and Meta Value
- 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
- Comparing timestamps in meta query doesn’t work
- Combine tax_query and meta_query in WP_Query
- 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 for custom post type objects in a taxonomy and with a meta value
- Display custom post type taxonomy and month
- CPT Meta Searching
- Is it possible to apply a meta_query to one specific post type in a query with multilple post types?
- meta_query compare >= not working but
- advanced search forms with 3 input text and that the main problem 3 input text
- WP_Query: include custom post type only with specific meta value
- How to alter WP-JSON main query or best practise for custom endpoints
- 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
- Filtering custom post type on a combination of custom taxonomies and custom fields?
- Meta query for custom post type ignored in main query
- Stuck in Order by more then one
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- Why is this query not working? (Standard posts + custom post type)
- search suggest – filter post type
- 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?
- Organize WordPress site, so it can maintain with huge database
- How to let users choose where to search for posts?
- Query based on custom fields start and end date
- 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?
- Querying multiple values from a single key
- find custom post type post by searching its custom field with my string
- Get category if used in a custom post type
- WP_Query of custom post type sorted by meta_key has unexpected results
- Custom Query: If One Post Object Field Value Is The Same As Another
- Query for post and costom post_type in same category filtered by meta for post_type
- If meta_value of meta_key is less than today’s date update meta key
- fetch custom post by meta key if key value is does not know
- Create a WP_Query where if the first value of the first row is equal to the second compare other value
- WP_Meta_Query object with conditionals
- Sorting by meta_key different to search criteria?
- Using WP meta query to show custom post types by a start and finish date
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- order the meta query results by 2 custom fields
- Dynamic template page calling shared taxonomies CPT or Plugin post type : how to clone taxonomy for plugin + set up dynamic shortcode
- build child and anchestor three from post parent
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Query posts by current ACF meta key value on single page as related posts
- meta query condition don’t work
- Custom query result empty on page 2
- Meta query and compare “!=” not working as expected
- 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
- Show posts from WP Custom Post Type selected from a field in a metabox
- meta query multiple values for the same key
- Custom post types – meta_query: search lesson which starts sooner
- Meta_Query refuses to return results
- Not able to get my custom search result using meta_query and tax_query together?
- Meta query broken since 4.7.4 Update
- How to shows CPT which has specific meta key?
- Querying, storing, and using data from 2 separate custom post types
- Query events post type after current date and timezone
- Conditional posts in WP_query for search
- 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
- Custom Query With Multiple Meta Key Value
- Trying to combine multiple WordPress queries
- using post_type with meta_query
- Ordering by multiple meta keys – Custom post type
- Filtering problem
- WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
- loop through custom post-type with two meta_keys
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- add_filter > posts_where works partially
- Get Posts ordered by a date custom meta field
- 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
- Meta_query question