Skip to content

Instantly share code, notes, and snippets.

@stevep
Last active June 21, 2017 15:59
Show Gist options
  • Save stevep/53cfafb869d577bb7d239e222f3316c0 to your computer and use it in GitHub Desktop.
Save stevep/53cfafb869d577bb7d239e222f3316c0 to your computer and use it in GitHub Desktop.
ACF Builder field filters

Registering Field

$builder = new FieldsBuilder('page_info');
$builder
  ->addText('title')
  ->setLocation('post_type', '==', 'page');
  
$builder = apply_filters('modify_page_info_fields', $builder);
acf_add_local_field_group($builder->build());

Theme 1 adds a WYSIWYG field

add_filter('modify_page_info_fields', function($builder) {
  $builder->addWysiwyg('extra_content');
  return $builder;
});

Theme 2 changes the title field's label

add_filter('modify_page_info_fields', function($builder) {
  $builder->modifyField('title', ['label' => 'Headline']);
  return $builder;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment