Skip to content

Instantly share code, notes, and snippets.

@mwangepatrick
Created March 10, 2023 08:10
Show Gist options
  • Save mwangepatrick/b749a830cd17f91f23124c8c9035f31d to your computer and use it in GitHub Desktop.
Save mwangepatrick/b749a830cd17f91f23124c8c9035f31d to your computer and use it in GitHub Desktop.
function register_custom_fields() {
$fieldArray = [];
array_push($fieldArray,
array(
'key' => 'sample_field_onee',
'label' => 'Sample Field',
'type' => 'text',
'prefix' => '',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'readonly' => 0,
'disabled' => 0,
),
);
if( function_exists('acf_add_local_field_group') ) :
acf_add_local_field_group(array (
'key' => 'lang_fields',
'title' => 'Language Fields',
'fields' => $fieldArray,
'location' => array (
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
));
endif;
};
add_action('acf/init', 'register_custom_fields');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment