Skip to content

Instantly share code, notes, and snippets.

@alanpilloud
Last active January 16, 2021 10:22
Show Gist options
  • Save alanpilloud/58e980f614b3216f47425abf9e50e53a to your computer and use it in GitHub Desktop.
Save alanpilloud/58e980f614b3216f47425abf9e50e53a to your computer and use it in GitHub Desktop.
PHP ACF Fields
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'checkbox',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'choices' => [
],
'allow_custom' => 0,
'save_custom' => 0,
'default_value' => [
],
'layout' => 'vertical',
'toggle' => 0,
'return_format' => 'value',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'clone',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'clone' => '',
'display' => 'seamless',
'layout' => 'block',
'prefix_label' => 0,
'prefix_name' => 0,
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'color_picker',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'default_value' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'date_picker',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'display_format' => 'd/m/Y',
'return_format' => 'd/m/Y',
'first_day' => 1,
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'date_time_picker',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'display_format' => 'd/m/Y g:i a',
'return_format' => 'd/m/Y g:i a',
'first_day' => 1,
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'email',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'file',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'return_format' => 'array',
'library' => 'all',
'min_size' => '',
'max_size' => '',
'mime_types' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'google_map',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'center_lat' => '',
'center_lng' => '',
'zoom' => '',
'height' => '',
],
// ...
// In order to use this field, you must add you Google API Key. You might want to replace the GMAPAPIKEY constant with your own key.
/**
* Register API Key for ACF Google maps
*/
add_filter('acf/fields/google_map/api', function ($api) {
$api['key'] = GMAP_API_KEY;
return $api;
});
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'group',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'layout' => 'block',
'sub_fields' => [
],
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'image',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'return_format' => 'array',
'preview_size' => 'thumbnail',
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'message',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'message' => '',
'new_lines' => 'wpautop',
'esc_html' => 0,
],
[
'key' => 'field_[group_name]_[field_name]',
'name' => '[group_name]_[field_name]',
...
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'number',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'min' => '',
'max' => '',
'step' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'oembed',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'width' => '',
'height' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'password',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'placeholder' => '',
'prepend' => '',
'append' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'post_object',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'post_type' => [
],
'taxonomy' => [
],
'allow_null' => 0,
'multiple' => 0,
'return_format' => 'object',
'ui' => 1,
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'radio',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'choices' => [
],
'allow_null' => 0,
'other_choice' => 0,
'save_other_choice' => 0,
'default_value' => '',
'layout' => 'vertical',
'return_format' => 'value',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'relationship',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'post_type' => [
],
'taxonomy' => [
],
'filters' => [
0 => 'search',
1 => 'post_type',
2 => 'taxonomy',
],
'elements' => '',
'min' => '',
'max' => '',
'return_format' => 'object',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'collapsed' => '',
'min' => 0,
'max' => 0,
'layout' => 'table',
'button_label' => '',
'sub_fields' => [
// Write your other fields here
[
'key' => 'field_subfield_example',
'label' => 'Subfield Example',
'name' => 'subfield_example',
'type' => 'text',
]
],
],
[
'key' => 'field_5981dad47e18f',
'name' => 'text',
'label' => 'My text field',
'type' => 'text',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'select',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'choices' => [
],
'default_value' => [
],
'allow_null' => 0,
'multiple' => 0,
'ui' => 0,
'ajax' => 0,
'return_format' => 'value',
'placeholder' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'placement' => 'top',
'endpoint' => 0,
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'taxonomy',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'taxonomy' => 'category',
'field_type' => 'checkbox',
'allow_null' => 0,
'add_term' => 1,
'save_terms' => 0,
'load_terms' => 0,
'return_format' => 'id',
'multiple' => 0,
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'textarea',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'new_lines' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'time_picker',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'display_format' => 'g:i a',
'return_format' => 'g:i a',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'message' => '',
'default_value' => 0,
'ui' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'url',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'default_value' => '',
'placeholder' => '',
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'user',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'role' => '',
'allow_null' => 0,
'multiple' => 0,
],
[
// Don't forget required attributes 'key', 'name' and 'label'
'type' => 'wysiwyg',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'default_value' => '',
'tabs' => 'all',
'toolbar' => 'full',
'media_upload' => 1,
'delay' => 0,
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment