# Fall Back to an ACF Options Value When a Field Is Empty

> Uses a site-wide default from your ACF options page whenever a post's own field is empty, such as a standard call-to-action text or banner.

- Type: PHP
- Runs: Run everywhere
- Category: [Custom Post Types & Fields](https://wpide.com/library/category/post-types/)
- Tags: acf, options-page, defaults
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/acf-default-from-options/

## Code

```php
// Post field and the options field with the default.
$wpide_acf_fallback_field  = 'cta_text';
$wpide_acf_fallback_option = 'default_cta_text';

add_filter( 'acf/load_value/name=' . $wpide_acf_fallback_field, function ( $value, $post_id ) use ( $wpide_acf_fallback_option ) {
    if ( ( null !== $value && '' !== $value && array() !== $value ) || 'options' === $post_id || 'option' === $post_id || is_admin() || ! function_exists( 'get_field' ) ) {
        return $value;
    }

    $default = get_field( $wpide_acf_fallback_option, 'option', false );

    return ( null === $default || '' === $default ) ? $value : $default;
}, 10, 2 );
```

## Notes

Set the post field and the options field that holds the default.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Fall Back to an ACF Options Value When a Field Is Empty" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
