A single-line text input for short plain-text values.
Overview
The Text field renders a single-line text input and returns a plain string. Use it for short content like headings, taglines, labels, phone numbers, email addresses, custom URLs, or any other single-line text setting in your theme.
For multi-line text use the Textarea field. For rich text with HTML use the Raw field.
Field Registration
📄<code>php
[
'id' => 'site_tagline',
'type' => 'text',
'title' => __( 'Site Tagline', 'your-textdomain' ),
'subtitle' => __( 'Shown below the logo in the header', 'your-textdomain' ),
'default' => __( 'Welcome to my site', 'your-textdomain' ),
'placeholder' => __( 'Enter a tagline…', 'your-textdomain' ),
]Field Options
| Option | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Unique field identifier — used as the option key |
type | string | ✅ | Must be text |
title | string | ✅ | Label shown above the field |
subtitle | string | — | Smaller descriptive text shown below the label |
desc | string | — | Alternative to subtitle — shown in the same position below the label |
placeholder | string | — | Placeholder text shown inside the input when empty |
default | string | — | Default value returned when nothing has been saved yet |
required | array | — | Conditional logic rules — see Conditional Logic |
subtitleanddescserve the same purpose — use whichever reads more naturally in your config. If both are provided,subtitletakes priority.
Return Value
Type: string
Returns the value entered by the user, or the default value if nothing has been saved yet. Returns an empty string '' if no default is set and nothing has been saved.
📄<code>php
$tagline = themeplus_get_option( 'site_tagline', 'Welcome to my site' );
// Returns: 'Welcome to my site'Usage Examples
Basic output
📄<code>php
$tagline = themeplus_get_option( 'site_tagline', '' );
if ( $tagline ) {
echo '<p class="site-tagline">' . esc_html( $tagline ) . '</p>';
}As a page heading
📄<code>php
$custom_title = themeplus_get_option( 'custom_page_title', get_the_title() );
echo '<h1 class="page-title">' . esc_html( $custom_title ) . '</h1>';In an HTML attribute
📄<code>php
$phone = themeplus_get_option( 'contact_phone', '' );
if ( $phone ) {
echo '<a href="tel:' . esc_attr( $phone ) . '" class="phone-link">' . esc_html( $phone ) . '</a>';
}As a CSS custom property
📄<code>php
$custom_font = themeplus_get_option( 'custom_font_name', '' );
if ( $custom_font ) {
echo '<style>:root { --custom-font: "' . esc_attr( $custom_font ) . '", sans-serif; }</style>';
}With a conditional field
📄<code>php
[
'id' => 'enable_announcement',
'type' => 'toggle',
'title' => __( 'Enable Announcement Bar', 'your-textdomain' ),
'default' => false,
],
[
'id' => 'announcement_text',
'type' => 'text',
'title' => __( 'Announcement Text', 'your-textdomain' ),
'placeholder' => __( 'Free shipping on all orders!', 'your-textdomain' ),
'default' => __( 'Free shipping on all orders!', 'your-textdomain' ),
'required' => ['enable_announcement', '==', true],
],