Hey there,
I’m trying to give a client the ability to change the fields on a CPT from the options page repeater.
When I register an options page via the ACF Composer, I reference get_field(“field_name”, “option”) inside a Fields’ file.
To achieve that, I had to register the options page and its custom fields early in the setup.php file as following:
$parent = acf_add_options_page([
'page_title' => 'Theme Options',
'menu_title' => 'Theme Options',
'menu_slug' => 'theme-options',
]);
acf_add_options_sub_page(array(
'page_title' => 'Options',
'menu_title' => 'Options',
'parent_slug' => $parent['menu_slug'],
));
acf_add_local_field_group(array(
'key' => 'group_5fc3255c2b7eb',
'title' => 'Stockists',
'fields' => array(
array(
'key' => 'field_5fc325713bedd',
'label' => 'Stockists',
'name' => 'stockists',
'type' => 'repeater',
'sub_fields' => array(
array(
'key' => 'field_5fc3257d3bede',
'label' => 'logo',
'name' => 'logo',
'type' => 'image',
),
array(
'key' => 'field_5fc325883bedf',
'label' => 'name',
'name' => 'name',
'type' => 'text',
),
),
),
),
'location' => array(
array(
array(
'param' => 'options_page',
'operator' => '==',
'value' => 'acf-options-options',
),
),
),
));
Is there a better way to achieve that with the cleaner file structure ACF Composer provides?