acf_with_default()
acf_with_default
Returns the supplied value if it is not empty; otherwise, returns the specified default value.
No Hooks.
Returns
mixed.
Usage
acf_with_default( $value, $default_value );
- $value(mixed) (required)
- Value.
- $default_value(mixed) (required)
- Default value.
Examples
#1 Usage example
acf_with_default( 'Hello', 'Goodbye' ); //> Hello acf_with_default( '', 'Goodbye' ); //> Goodbye
Changelog
| Since 5.9.0 | Introduced. |
acf_with_default() acf with default code ACF 6.8.8
function acf_with_default( $value, $default_value ) {
return $value ? $value : $default_value;
}