I am building some custom fields for a website and was wondering how can the default value of a field take the post’s title?
This is my code
array (
'key' => 'field_551cfewr3ca5bef',
'label' => 'Push Notification Description',
'name' => 'push_notification_description',
'type' => 'text',
'default_value' => "",
),
You would create an acf/load_field filter https://www.advancedcustomfields.com/resources/acf-load_field/ and in this filter set the default value to what you want.
But this will really not work. This issue would be that on a new post, there is no title, so the default value would be not be populated with anything useful.
If what you’re looking for is to set this field with the post title when the post is saved then you should look at creating an acf/save-post filter https://www.advancedcustomfields.com/resources/acf-save_post/. In this filter you could get the title of the post and update the field with it https://www.advancedcustomfields.com/resources/update_field/