Skip to content

Instantly share code, notes, and snippets.

@Asikur22
Forked from ajskelton/WP Customizer - Text
Last active November 15, 2019 18:18
Show Gist options
  • Save Asikur22/11c1328ce619cfa6b8ce9a5c110e2273 to your computer and use it in GitHub Desktop.
Save Asikur22/11c1328ce619cfa6b8ce9a5c110e2273 to your computer and use it in GitHub Desktop.
Add a Text field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_text_setting_id', array(
'capability' => 'edit_theme_options',
'default' => 'Lorem Ipsum',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( 'themeslug_text_setting_id', array(
'type' => 'text',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Text' ),
'description' => __( 'This is a custom text box.' ),
) );
<?php echo esc_html( get_theme_mod( 'themeslug_text_setting_id' ) ); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment