Last active
May 17, 2017 21:13
-
-
Save jongacnik/5592db95a31e4bfac8596cd1f5f8e95e to your computer and use it in GitHub Desktop.
ACF model via php example ~ https://www.advancedcustomfields.com/resources/register-fields-via-php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('acf/init', 'register_post_fields'); | |
function register_post_fields () { | |
$location = [ | |
[ | |
[ | |
'param' => 'post_type', | |
'operator' => '==', | |
'value' => 'post' | |
] | |
] | |
]; | |
$fields = [ | |
[ | |
'key' => 'field_1', | |
'label' => 'Subtitle', | |
'name' => 'subtitle', | |
'type' => 'text' | |
], | |
[ | |
'key' => 'field_2', | |
'label' => 'Some URL', | |
'name' => 'some_url', | |
'type' => 'url' | |
] | |
]; | |
acf_add_local_field_group([ | |
'key' => 'group_post_1', | |
'title' => 'Post Fields', | |
'fields' => $fields, | |
'location' => $location | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment