I'm using the Advanced Custom Fields plugin and I have created some options pages with:
if (function_exists('acf_add_options_page')) {
website_settings_init();
}
function website_settings_init() {
$website_settings = acf_add_options_page(array(
'page_title' => 'Website Settings',
'menu_title' => 'Website Settings',
'menu-slug' => 'website-settings',
'post_id' => 'website-settings',
'redirect' => false
));
$form_settings = acf_add_options_sub_page(array(
'page_title' => 'Form Settings',
'menu_title' => 'Form Settings',
'menu-slug' => 'form-settings',
'post_id' => 'form-settings',
'parent_slug' => $website_settings['menu_slug']
));
$contact_details = acf_add_options_sub_page(array(
'page_title' => 'Contact Details',
'menu_title' => 'Contact Details',
'menu-slug' => 'contact-details',
'post_id' => 'contact-details',
'parent_slug' => $website_settings['menu_slug']
));
}
I have a field group that is visible if Options Page = Form Settings.
One of these fields is 'thank_you_page' which returns a Page ID.
I read https://www.advancedcustomfields.com/resources/get-values-from-an-options-page/ which describes how you can get values from an options page field using get_field('field_name', 'option');
I have tried:
get_field('thank_you_page', 'option');
This returns null
. I've tried both 'option'
and 'options'
. However, if I try:
get_field('thank_you_page', 'form-settings');
I get the saved Page ID. What am I misunderstanding/doing wrong? Is it because it is an options sub page?
I'm using Wordpress 4.9.8 and ACF Pro 5.7.7
Thanks