Home › Forums › Backend Issues (wp-admin) › How can I register fields via php when a post is saved › Reply To: How can I register fields via php when a post is saved
When you are registering the fields in when you call acf_add_local_field_group()
you need to get the value that was previously saved.
if( function_exists('acf_add_local_field_group') ):
$label = 'Default Label';
// code to do something like get a new field label will go here
// what you need to do depends on where you're saving the
// value that you want to use
acf_add_local_field_group(array(
'key' => 'group_1',
'title' => 'My Group',
'fields' => array (
array (
'key' => 'field_1',
'label' => $label,
'name' => 'sub_title',
'type' => 'text',
)
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'test_type_1',
),
),
),
));
endif;
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.