I am trying to display text from custom input but in vain. I'm developing a custom WordPress theme for my site. I've added the field to the Wordpress customizer, but the content of the field is not displaying on the page.
function prolifictheme_add_customizer_content( $wp_customize ) {
$wp_customize->add_section( 'prolific_theme_text_setting_id', array(
'title' => __( 'General Settings', 'prolific-theme' ),
'priority' => 30,
'description' => __( 'Customize the layout of your site homepage', 'prolific-theme' )
) );
$wp_customize->add_setting( 'prolific_theme_text_setting_id', array(
'capability' => 'edit_theme_options',
'default' => 'Text Goes Here',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( 'prolific_theme_text_setting_id', array(
'type' => 'text',
'section' => 'prolific_theme_text_setting_id', // Add a default or your own section
'label' => __( 'Main Banner Title' ),
'description' => __( 'Enter title of not more than 35 Words.' ),
) );
}
add_action( 'customize_register', 'prolifictheme_add_customizer_content' );
Display Text
<h1><?php echo get_theme_mod( 'prolific_theme_text_setting_id' ); ?></h1>
CodePudding user response:
Your code worked out of the box. Where did you put the text? Insert it to the bottom of the header.php
and you will see it. I think your are searching in the wrong template for the result.