Thanks for the question, it is very clear to see what you are attempting to do.
The above will not be easy, but it is not impossible. Lets start with filtering the products that are ‘blue’.
You can use this tutorial here to query sub field values:
This tutorial may seem a bit complex, but your task here is to find all the $rows in the postmeta table, where ‘blue’ was selected.
$rows loop, you can find the post_id like so
$post_id = $row->post_id;
This allows to get the product ID that contains this ‘blue’ color. Instead of assigning this to a variable called
$post_id, you should append it to an array like so:
$ids = $row->post_id;
After your loop is complete, you should have a populated $ids array which you can now use in a WP_Query argument in the ‘posts__in’ arg!
To show the blue image as the featured one, just loop through all the repeater rows and then match the ‘product_colour’ value to the current queried color. When a match is found, display that image!
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!
Sorry for the issues with ACF's API SSL certificate this morning. We've resolved it and your activations and downloads should be back to normal again. Thanks! ^LG— Advanced Custom Fields (@wp_acf) November 2, 2022
© 2022 Advanced Custom Fields.