Support

Account

Home Forums ACF PRO Loop on location fields : dynamically creation Reply To: Loop on location fields : dynamically creation

  • Hi @manhattanjazz

    I believe you can do it like this:

    if( function_exists('acf_add_local_field_group') ):
        $ids = array('66','691');
        $args = array (
            ...
            ...
            ...
            'location' => array (
                array (
                    array (
                        'param' => 'page',
                        'operator' => '==',
                        'value' => '815',
                    ),
                ),
            ),
            ...
            ...
            ...
        );
    
        foreach( $ids as $id ){
            $args['location'][] = array (
                array (
                'param' => 'page',
                'operator' => '==',
                'value' => $id,
                ),
            );
        }
    
        acf_add_local_field_group($args);
    
    endif;

    I hope this helps.