We build easy to manage, secure and Mobile friendly Websites.

How To Add Text Field to WordPress Customizer

In this tutorial, I will be showing you how to text field to WordPress customizer.

I have discussed about the parameters for add_setting() and add_control() functions in my previous tutorial.

First let us create theme option section for the text field

// Input type - Section */
	$wp_customize->add_section('themeslug_section_id', array(
        'title'    => esc_html__('Input Types Section', 'themeslug'),
        'description' => 'This tutorial shows how to add Input Types to WordPress Customiser',
        'priority' => 1,

Create setting for text field

$wp_customize->add_setting('themeslug_text_id', array(
        'default'        => '',
		'sanitize_callback' => 'sanitize_text_field'       

Create control for text field

$wp_customize->add_control('themeslug_text_id', array(
        'label'    => esc_html__('Input Type: Text', 'themeslug'),
        'type' => 'text',
        'priority' => 1,
        'section'   => 'themeslug_section_id',
        'setting'  => 'themeslug_type',
        'capability' => 'edit_theme_options',


Add the code below to your page

<?php esc_html_e( get_theme_mod( 'InputType_text_id' ) ); ?>

Leave a Reply

Your email address will not be published. Required fields are marked *