If I am reading your question right, you need AND
not OR
for the meta query relation
'relation' => 'AND',
I don’t see where you’ve set the $product_*
values either. You should be using $_GET['product_color']
(etc), but you need to sanitize that user supplied data. I would use a “whitelist” technique if it were me:
$whitelist = array(
'red' => 'red',
'blue' => 'blue'
);
if (isset($_GET['product_color']) && isset($whitelist[$_GET['product_color']])) {
$product_color = $whitelist[$_GET['product_color']];
}
echo $product_color;
If this is a secondary query you should be good, if this is the main query on the page you should be using pre_get_posts
.
Related Posts:
- How to only display posts whose meta_value field is not empty?
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- WP_Query with meta_value LIKE ‘something%’
- Sorting meta_value as integer doesn’t work
- Add a default meta_value to new posts
- Ordering by meta_value AND date NOT WORKING with wp_query
- How to use Meta Value Compare in WP_Query For Max and Min numbers
- Custom WP Query from meta_value stored as serialised array
- meta_query works locally but not on live server
- Ordering Posts Type A by Custom Fields of related Post Type B
- Custom query for sidebar isn’t returning results
- Need wp_query to return all children and grandchildren
- new WP_Query to get max price meta value not working
- Query multiple meta values
- Why isn’t my `meta_query` array functioning properly?
- How to orderby multiple meta fields if some fields are empty
- Meta_query on same meta key, with diffrenct values
- How to extract specific post
- Meta Query relation “AND” then set array accordingly
- Does meta_value (array) work with ‘orderby’?
- WP Query Meta Value – How To Identify Specific, Unique Values?
- query post by author gender
- Meta query with compare by more than 2 fields
- Order (by ASC) posts with meta_key so posts without values are last
- Save queried result into database
- WP_Query multiple value not working
- Gather same custom field values in one value in a select tag with wp_query
- Order posts by more than one variable (meta_key and publish date AND time)
- how to query for meta_value have array
- Sorting Posts with meta value not working
- Cannot order by in WP_Query
- Query to get all the posts of more than 2 meta_value having same meta_key?
- Order by meta values
- query_posts, oderby meta_value & print “future” posts
- Get posts by meta value except one post [closed]
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Wp_redirect and sending variables
- how does $wpdb differ to WP_Query?
- WP_Query – filter or directly?
- WP_Query with checkbox meta_query
- How can I save an array from a random post sequence for later use?
- Does WordPress generate an automatic page for post formats?
- Why is WP-Query spelled like it is?
- How to add custom query filters in WP_User_Query
- Limit search results to exact match
- Which custom query am I in and how can I access its properties & methods?
- Pagination not working Search posts
- Does using a custom query_var create a security hole?
- How to speed up wp_query, took more 5s to run against 100k posts
- How to sort posts in admin by titles with dd.mm.yyyy format?
- Why I can’t get old posts instead of recent with WP_Query?
- How get posts from a subcategory of a category by name?
- Date query not inclusive despite parameter being true
- Change default ordering of taxonomy terms – pre_get_terms
- Exclude old events from WP_Query with date saved in a `meta_key`
- WP_Query arguments to fetch custom post type posts which are in certain category?
- WP_Query loop within WP_Query loop
- current_post not working – give me -1 for every post
- How to fetch only media that was already attached to a post/page?
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- WP_Query won’t retrieve raw HTML?
- Remove a specific category ID from related post
- Order posts by taxonomy count
- Any number in meta key (wp query)
- Custom Metabox data slow query on Admin init
- WordPress Comments sort by custom meta key
- Order by summing multiple values
- Understanding the orderby in WP_Query?
- Need Help For WPQuery
- Posts published last 10 minutes
- How should I approach changing the template & $query as part of a shortcode’s execution?
- Getting additional columns from sql
- get all posts associated with a custom taxonomy
- complex get_posts() query to select child pages
- How to add $args to any running wp_query from function.php?
- Get next/prev image/attachment in time with date query
- Reordering content using a meta value
- How to add a recent post function to a text widget I created for practice?
- Optimising WP_Query with ACF Fields
- WP_Query no result if keyword contains number
- WP_QUERY order posts by two combined meta_value dates
- Order by value of Custom Field using url string
- update_post_meta performance in a loop woocommerce
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- query_posts() doesn’t seem to be called in my page
- WP_Query returns empty if meta_query has more than 7 values
- query.php – multiple is_category functions
- How to get several fields from wp_query?
- Overwriting auto-appended NOT IN query in WP_Query
- query_posts with sorting on a custom datestamp
- Conditionals in WP_Query
- Why WP_Query in functions.php is not working when get_posts works?
- Query Posts by date range with fixed beginning and end
- query by meta value then date and not empty meta value
- Issue with sorting by post date and custom post type
- Is it possible to use WP Query to orderby custom meta value and custom taxonomy?
- Display all custom meta field values from the database using ACF Repeater
- Can’t get LIKE to work with wp_query [closed]
- How do I have multiple metaqueries inside one wordpress query
- Can I use WP_Query to find a post with a particular menu_order?