Home › Forums › Add-ons › Repeater Field › Query by Repeater row subfield checkbox › Reply To: Query by Repeater row subfield checkbox
Personally, I use $wpdb to query repeater fields. This might not be the best way (you might want to use wp_cache_set/wp_cache_get if this turns into a performance issue), but it works for me.
If I understand your situation properly, I imagine something like this (warning, untested code):
global $wpdb;
return $wpdb->get_col("SELECT DISTINCT post_id FROM wp_postmeta m INNER JOIN wp_posts p ON m.post_id = p.id AND p.post_type='artist' WHERE m.meta_key LIKE 'video\_%\_tag' AND m.meta_value='featured'");
If I am not mistaken about your setup, this would return a list of artist post ids where any of the tags in your video repeater is set to ‘featured’.
Note that, as written, this would return both published and unpublished posts. If you wanted just published posts you’d need to add that constraint to the query (in the where clause, something like: AND p.post_type=’publish’).
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.