Home Forums General Issues Dynamic population of select repeater prevents options from saving


Dynamic population of select repeater prevents options from saving

  • Hi there

    I couldn’t manage to find this issue logged on the forum already…

    I have managed to dynamically populate a select field as per the tutorial here:

    This was altered as the select choices needed to be the titles of certain pages (children of parent page ID 8)

    // populate select repeater with restaurant names
        function my_acf_load_field( $field )
            // reset choices
            $field['choices'] = array();
            // get restaurant locations (children of page id 8)
            $args = array(
                'post_type' => 'page',
                'post_parent' => 8,
                'orderby' => 'menu_order',
                'order' => 'ASC'
            // The Query
            $the_query = new WP_Query( $args );
            // The Loop
            if ( $the_query->have_posts() ) {
                while ( $the_query->have_posts() ) {
                    $value = get_the_title();
                    $label = get_the_title();
                    $field['choices'][ $value ] = $label;
            /* Restore original Post Data */
            return $field;
        // v4.0.0 and above
        add_filter('acf/load_field/name=restaurant_name', 'my_acf_load_field');

    Populating the select fields works great, as I’d hoped. The problem now is that on the ‘Edit Field Group’ page, my choices in the ‘Locations’ and ‘Options’ boxes are no longer saving. Once I disable the above function, the options are back again.

    Hope this makes sense, any help appreciated!


  • This same thing is happening to me. Still searching through the forum to find solutions. Did you by chance ever get this working?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.