Skip to content

Instantly share code, notes, and snippets.

@mklasen
Created July 23, 2018 08:39
Show Gist options
  • Save mklasen/66da8bb0fd92bbcd5ab41c5ef4b5d68d to your computer and use it in GitHub Desktop.
Save mklasen/66da8bb0fd92bbcd5ab41c5ef4b5d68d to your computer and use it in GitHub Desktop.
Example fields for ACF (simple, in PHP)
if ( function_exists( 'acf_add_local_field_group' ) ):
acf_add_local_field_group( array(
'key' => 'key_name',
'title' => 'Title',
'fields' => array(
array(
'label' => 'Group',
'key' => 'key',
'name' => 'name',
'type' => 'group',
'layout' => 'table',
'sub_fields' => array(
array(
'label' => 'Repeater',
'key' => 'repeater',
'name' => 'repeater',
'type' => 'repeater',
'sub_fields' => array(
array(
'key' => 'field',
'label' => 'field',
'name' => 'field',
'type' => 'text'
),
),
),
array(
'label' => 'Repeater',
'key' => 'repeater',
'name' => 'repeater',
'type' => 'repeater',
'sub_fields' => array(
array(
'key' => 'field',
'label' => 'field',
'name' => 'field',
'type' => 'text'
),
),
)
)
),
array(
'key' => 'field_name',
'label' => 'field_label',
'name' => 'field_name',
'type' => 'type'
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'post', // only post post type
),
),
),
) );
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment