I'm using the Customizer API to enable/disable different sections of a website.
When I have the customizer window open it seems that get_theme_mod()
is returning a value ok. However as soon as I save and close the customizer window, get_theme_mod()
does not return anything.
I've seen some other questions about using type="option"
and get_option()
but I want to see if I can get this to work.
My settings look like this:
$wp_customize->add_setting( 'my_banner_setting', array(
'default' => '1',
'sanitize_callback' => 'my_sanitize_checkbox',
) );
And then I get them like this:
if ( get_theme_mod( 'my_banner_setting' ) == 1 ) {
get_template_part( 'sections/banner' );
}
Is there something I'm missing?