Support

Account

Home Forums Bug Reports Can't Reuse Custom Field Groups for Multiple Options Pages

Solving

Can't Reuse Custom Field Groups for Multiple Options Pages

  • To allow customization to my archive pages, I have create a custom field group with a title and a content field.

    My plan is to create an options page under each post type to allow for the these fields to be completed.

    The problem I am having is that the custom field group is only holding one set of values between the multiple options pages in the admin.

    I know I can create a separate custom field group with the same fields for each post type, but for the sake of DRY I’m wondering if there are any alternatives.

    Thanks! Here’s the code I am using

    if ( function_exists( 'acf_add_options_sub_page' ) ) {
    
    	acf_add_options_sub_page( array(
    			'title'  => 'Horse Archive',
    			'parent' => 'edit.php?post_type=horse'
    	) ); 
    
    	acf_add_options_sub_page( array(
    			'title'  => 'FAQ Archive',
    			'parent' => 'edit.php?post_type=faq'
    	) );
    
    }
    
  • Hi @christianmagill

    All options pages will save it’s data to the same global ‘options’ post object. This means that if you have the same field name on 2 options pages, they will not save individual values, but only 1.

    Perhaps you will need to duplicate your field group (using a post duplicator plugin) and create a field group for each options page. You can then prefix the field names with ‘hourse_’ or ‘faq_’.

    I hope that helps.

    Thanks
    E

  • If any are interested, I’ve finished adding field group duplicators to my options page adder plugin. I would be interested in any feedback or bug reports before I merge it with the master repo. The duplicator basically does all the work of renaming all the fields and other necessary changes so that you can use the same field group multiple times and all of them will be automatically updated if there are changes in your master copy of the group.

    https://github.com/Hube2/acf-options-page-adder/tree/Fieldset-Duplicator

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Can't Reuse Custom Field Groups for Multiple Options Pages’ is closed to new replies.