Support

Account

Home Forums General Issues Returning a value from a function in a custom field or metabox Reply To: Returning a value from a function in a custom field or metabox

  • 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');