New customizer setting not showing value

Edit: It’s working now, please lock the thread.

I am using the Understrap framework (Underscores plus Bootstrap).

$wp_customize->add_section( 'understrap_theme_post_options', array(
    'title'       => __( 'Theme Post & Archive Settings', 'understrap' ),
    'capability'  => 'edit_theme_options',
    'description' => __( 'Post and Archive Settings', 'understrap' ),
    'priority'    => 160,
) );

$wp_customize->add_setting( 'understrap_show_updated_post', array(
    'default'           => 'no',
    'type'              => 'theme_mod',
    'sanitize_callback' => 'understrap_theme_slug_sanitize_select',
    'capability'        => 'edit_theme_options',
) );

$wp_customize->add_control( new WP_Customize_Control(
    $wp_customize,
    'understrap_show_updated_post_cn', array(
        'label'    => __( 'Show Last Updated Date', 'understrap' ),
        'section'  => 'understrap_theme_post_options',
        'settings' =>  'understrap_show_updated_post',
        'type'     => 'select',
        'choices'  => array(
            'yes'      => __( 'Yes', 'understrap' ),
            'no'       => __( 'No', 'understrap' ),
        ),
        'priority'    => '10',
    )
) );

I have added this code in Customizer.php

Everything works fine, values are being saved because when I refresh the Customizer, I can see the updated value. However, when I do this on template-tags.php, it does not output anything:

echo get_theme_mod( 'understrap_show_updated_post' );

What am I doing wrong?

0

Leave a Comment