When multiple values are passed for multiple fields then you’ll need to use multiple nested meta queries.
Looking at this query string
I’m going to assume that you want
(size == small OR size == large) AND (color == black OR color == white)
You’ll need to figure out out to put this into your loop, but the meta query you would need is something like this
$meta_query = array( 'relation' => 'AND', array( 'relation' => 'OR', array( 'key' => 'size', 'value' => '"small"', 'compare' => 'LIKE' ), array( 'key' => 'size', 'value' => '"large"', 'compare' => 'LIKE' ), array( 'relation' => 'OR', array( 'key' => 'color', 'value' => '"black"', 'compare' => 'LIKE' ), array( 'key' => 'color', 'value' => '"white"', 'compare' => 'LIKE' ), ), );
A word of caution/warning, as the number filters grow and the number of selections made in each filter grows these like queries will take longer and longer to process until they finally time out and likely time out until it prevents the page from loading.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
📣 “ACF Chat Fridays”— Advanced Custom Fields (@wp_acf) January 31, 2023
The ACF team holds their first open office hours this Friday! Come and talk ACF, and ask questions about building sites with the plugin.
We’d love to see you there!
📆 Friday 3rd Feb - 3pm UTC
👉 Register here - https://t.co/3UtvQbE4CU pic.twitter.com/oTwW9K1XQ0
© 2023 Advanced Custom Fields.