Sorry, it’s a lot of code, but thank you for your time. I don’t know the best way to share it, but hopefully this is okay.
I’m using this filter:
to add subfields to a field of type “Group” (because I need them to be dynamic).
Here is the group field:
acf_add_local_field_group(array( 'key' => 'group_604dda92ef574', 'title' => 'Archives', 'fields' => array( array( 'key' => 'field_604de6ee3ffc6', 'label' => 'Archives', 'name' => 'archive_options', 'aria-label' => '', 'type' => 'group', 'instructions' => 'Archive pages are lists such as the main blog page, search results, and category and tag pages. Choose layout, appearance, and other options for such pages from the list below for each post type.', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'layout' => 'block', 'acfe_seamless_style' => 0, 'acfe_group_modal' => 0, 'acfe_group_modal_close' => 0, 'acfe_group_modal_button' => '', 'acfe_group_modal_size' => 'large', 'sub_fields' => '', ), ), 'location' => array( array( array( 'param' => 'options_page', 'operator' => '==', 'value' => 'theme-options', ), ), ), 'menu_order' => 10, 'position' => 'normal', 'style' => 'seamless', 'label_placement' => 'top', 'instruction_placement' => 'label', 'hide_on_screen' => '', 'active' => true, 'description' => '', 'show_in_rest' => 0, 'acfe_display_title' => '', 'acfe_autosync' => '', 'acfe_form' => 0, 'acfe_meta' => array( '604dddb8749bf' => array( 'acfe_meta_key' => '', 'acfe_meta_value' => '', ), ), 'acfe_note' => '', ));
The ‘sub_fields’ => ”, part is getting loaded from a function in functions.php using that filter.
Here’s the function:
Here’s what I get when I look at the php that is being generated by ACF:
And here’s how it looks on my Theme Options page:
Each post type has the same set of options. Everything else on the options page is saving just fine, but not this stuff.
My fields are getting generated but nothing is saving. I originally said that it was saving to the database, but it’s not now.
The database looks kind of weird, too:
Any idea what I’m doing wrong? I assume there’s something seriously wrong with that function even though the fields are getting generated.
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!
📣 “ACF Chat Fridays”— Advanced Custom Fields (@wp_acf) January 31, 2023
The ACF team holds their first open office hours this Friday! Come and talk ACF, and ask questions about building sites with the plugin.
We’d love to see you there!
📆 Friday 3rd Feb - 3pm UTC
👉 Register here - https://t.co/3UtvQbE4CU pic.twitter.com/oTwW9K1XQ0
© 2023 Advanced Custom Fields.