Description
The Text field creates a basic text input, useful for storing single string values.
Screenshots
Changelog
- Formatting setting removed in version 5.0.0.
Settings
Default Value
The default value shown when creating a new post.Required
Found on the Validation tab, this prevents the field from accepting empty values. Defaults to off.Character Limit
Limits the number of characters allowed.Instructions
Shows instructions when submitting data.Placeholder Text
Appears within input when no value exists.Prepend
Adds a visual text element before the input.Append
Adds a visual text element after the input.
Template usage
Display value
This example demonstrates how to display a Text field named “heading” within a <h2>
tag. We don’t recommend outputting any ACF value without any sort of protection or escaping.
<h2><?php echo esc_html( get_field('heading') ); ?></h2>
Load value
This example demonstrates how to load the value of a Text field named “confirm” and perform an action based on its value.
$confirm = get_field('confirm');
if( $confirm === 'SEND_EMAIL' ) {
// Do something.
}
Supercharge Your Website With Premium Features Using ACF PRO
Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.