Text

Last updated May 22, 2023

Description

The Text field creates a basic text input, useful for storing single string values.

Screenshots

Creating a Text field within an ACF field group.

Creating a Text field within an ACF field group.

The Presentation tab lets you control how the Text field will appear.

The Presentation tab lets you control how the Text field will appear to content editors.

How the Text field appears to content editors. Changes made on the Presentation tab, such as placeholder text, are reflected here.

How the Text field appears to content editors. Changes made on the Presentation tab are reflected here.

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.

Explore Features View Pricing

PRO Features
ACF Blocks
Options Pages
PRO Fields
Repeater
Flexible Content
Gallery
Clone