Back to Community

Troubleshooting the ACF acf/load_field Filter: Why Your Field Isn't Prefilling

38 threads Sep 16, 2025 PluginAdvanced custom fields (acf®)

Content

Many developers use the powerful acf/load_field filter in Advanced Custom Fields (ACF®) to dynamically prefill or modify field properties. A common issue, as seen in user reports, is writing the filter correctly but seeing no change in the field on the edit screen. This guide will explain why this happens and how to fix it.

The Common Problem: Filter Execution Timing

The most frequent cause of the acf/load_field filter not working is its execution timing. This filter runs very early, often before the post is loaded in the WordPress admin. If your logic depends on a specific $post_id or post status, it may run in a context where that information is not yet available, causing the filter to have no effect.

Why This Happens

The acf/load_field filter is designed to load or alter the field's setup before it is rendered. It is not intended for loading values based on the current post's content in the same way as the acf/load_value filter. Using it for the wrong purpose is a common pitfall.

How to Fix It: Solutions and Best Practices

Solution 1: Use the Correct Filter for Prefilling Values

If your goal is to prefill a field's value (like an auto-increment number), you should likely use the acf/load_value filter instead. This filter is specifically designed for populating a field's value based on the current post or other conditions.

// Prefill a field's VALUE using acf/load_value
add_filter('acf/load_value/name=untertitel', 'prefill_field_value', 10, 3);
function prefill_field_value( $value, $post_id, $field ) {
    // If no value is set yet, provide a default
    if( empty($value) ) {
        $value = 'Test';
    }
    return $value;
}

Solution 2: Ensure Proper Context in acf/load_field

If you genuinely need to use acf/load_field to change a property like readonly, you must ensure your code checks the context to avoid running on unintended admin screens.

// Safely modify field properties using acf/load_field
add_filter('acf/load_field/name=untertitel', 'modify_field_properties');
function modify_field_properties( $field ) {
    // Only modify the field on the post edit screen for a specific post type
    if( is_admin() && function_exists('get_current_screen') ) {
        $screen = get_current_screen();
        if ( $screen && $screen->post_type === 'your_special_post_type' ) {
            $field['readonly'] = true;
        }
    }
    return $field;
}

Solution 3: Verify the Field Key or Name

A simple typo in the field name or key in your filter can cause it to not fire. Double-check that the identifier in your filter hook (name=untertitel or key=field_12345abc) exactly matches the field's name or key in your ACF field group.

Conclusion

The acf/load_field filter is a powerful tool for modifying field objects, but it must be used in the right context. For prefilling values, acf/load_value is often the more appropriate choice. Always add conditional checks to your functions to ensure they only run where intended. By following these practices, you can reliably dynamically control your ACF fields.

Related Support Threads Support