In the case of options pages, acf is just a wrapper for the WP functions get_option() and update_option(). There is nothing built into these functions that allows for duplicate field names. In fact, the database is set up so that the “option_name” value must be unique.
There is a work-a-round for this that is not well known. When saving options ACF prefixes the option name with “options_”. You can alter this by altering the post ID used for the options page. This is one of the settings when adding an options page. For example, if you used the post ID of one page or “theme_options” and the post ID of “some_other_options” for a second page and both options pages have a field name “some_field_name” ACF will store one at “theme_options_some_field_name” and the other at “some_other_options_some_field_name”
You just need to give the correct post ID when getting these options, instead of
get_field('my_field', 'options') you would do
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!
© 2023 Advanced Custom Fields.