Home › Forums › Backend Issues (wp-admin) › WP Query – Multiple values in ACF Checkbox › Reply To: WP Query – Multiple values in ACF Checkbox
That sounds really interesting – great article, and thanks. I’m not advanced enough with PHP to be sure how you would tackle the part that cycles through the repeaters in your example for a checkbox field:
if (have_rows('colors', $post_id)) {
while (have_rows('colors', $post_id)) {
the_row();
$color = get_sub_field('color');
if (isset($saved_values[$color])) {
continue;
}
add_post_meta($post_id, $meta_key, $color, false);
$saved_values[$color] = $color;
}
}
Presumably we can’t do if(have_rows())
and while(have_rows())
if there are no rows?
I’m interested in doing this BEFORE the site I’m building gathers a lot of content, and learning something I can use again in future too. Would you mind showing me how you’d do this for a non-repeater?
Thanks so much.
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.