Home › Forums › Add-ons › Options Page › Get all fields from option page › Reply To: Get all fields from option page
Yes, just like @elardael said. You would add this as a parameter in to acf_add_options_sub_page
or acf_add_options_page
.
add_action('acf/init', function() {
if (function_exists('acf_add_options_sub_page')) {
acf_add_options_sub_page(array(
'post_id' => 'unique_id',
'menu_title' => 'Event Settings',
'parent_slug' => 'edit.php?post_type=events',
));
acf_add_options_sub_page(array(
'post_id' => 'another_unique_id',
'menu_title' => 'Cookie Settings',
'parent_slug' => 'edit.php?post_type=cookies',
));
}
);
This would allow you to be more certain and specific when getting fields from option pages. Rather than using get_field('field_name', 'options');
you can type get_field('field_name', 'unique_id');
and be certain that the field is from that specific options page.
Now you can also have field names with the same name on different option pages, not possible if you don’t register a post_id
.
Also, as mentioned before you, can get all fields from an entire options page; get_fields('unique_id');
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 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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.