Home › Forums › Add-ons › Options Page › Select specific repeater rows from an options page › Reply To: Select specific repeater rows from an options page
// loading the field
add_action('acf/load_field/name=select_field_name', 'load_select_field_name_choices');
function load_select_field_name_choices($field) {
$choices = array();
if (have_rows('repeater_field_name', 'options')) {
while (have_rows('repeater_field_name', 'options')) {
the_row();
$title = get_sub_field('services_title');
$choices[$title] = $title;
} // end while have rows
} // end if get field
} // end function
// displaying the values
$selections = get_field('select_field_name');
// this is assuming that the select field returns an array of selected values
if (!empty($selections)) {
if (have_rows('repeater_field_name', 'options')) {
while (have_rows('repeater_field_name', 'options')) {
the_row();
$title = get_sub_field('services_title');
if (in_array($title, $selections)) {
// get other sub fields from the repeater and display here
} // end if selection is selected
} // end while have rows
} // end if get field
} // end if !empty
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’re reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U
— Advanced Custom Fields (@wp_acf) May 22, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.