Hello,
Is there a simple or recommended way to return a value from a function within a custom field or metabox area on the post edit screen?
For example, I tried using this approach but it doesn’t work:
function acf_load_shorturl_field( $field ) {
// Get shorturl value
$field = get_shorturl();
// return the field
return $field;
}
add_filter('acf/load_field/name=shorturl', 'acf_load_shorturl_field');
Thanks for any help or suggestions.
John
Looks like I was close. I needed to set the ‘default_value’ attribute:
function acf_load_shorturl_field( $field ) {
// Get shorturl value
$field['default_value'] = get_shorturl();
// return the field
return $field;
}
add_filter('acf/load_field/name=shorturl', 'acf_load_shorturl_field');