WP Customizer – Text Box
January 10, 2023
In functions.php
:
function add_custom_text_area( $wp_customize ) {
$wp_customize->add_section( 'text_item_name', array(
'title' => __( 'General Settings', 'TextItemName' ),
'priority' => 30,
'description' => __( 'Customize the layout of your site homepage', 'TextItemName' )
) );
$wp_customize->add_setting( 'text_item_name', array(
'capability' => 'edit_theme_options',
'default' => 'Text Goes Here',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( 'text_item_name', array(
'type' => 'text',
'section' => 'text_item_name',
'label' => __( 'Enter the title here' ),
'description' => __( 'Enter title of not more than 35 Words.' ),
) );
}
add_action( 'customize_register', 'add_custom_text_area' );
In frontend file:
<p><?php echo get_theme_mod( 'text_item_name' ); ?></p>