<?php add_action( 'customize_register', 'wts_register_theme_customizer' ); /* * Register Our Customizer Stuff Here */ function wts_register_theme_customizer( $wp_customize ) { // Create custom panel. $wp_customize->add_panel( 'text_blocks', array( 'priority' => 500, 'theme_supports' => '', 'title' => __( 'Text Blocks', 'wts' ), 'description' => __( 'Set editable text for certain content.', 'wts' ), ) ); // Add section. $wp_customize->add_section( 'custom_cta_title_text' , array( 'title' => __('Change CTA Title Text','wts'), 'panel' => 'text_blocks', 'priority' => 10 ) ); // Add setting $wp_customize->add_setting( 'cta_title_text_block', array( 'default' => __( 'default text', 'wts' ), 'sanitize_callback' => 'sanitize_text' ) ); // Add control $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'custom_cta_title_text', array( 'label' => __( 'CTA Title Text', 'wts' ), 'section' => 'custom_cta_title_text', 'settings' => 'cta_title_text_block', 'type' => 'text' ) ) ); // Sanitize text function sanitize_text( $text ) { return sanitize_text_field( $text ); } }
Displaying in the Front End
<?php echo get_theme_mod( 'cta_title_text_block'); ?>