Reputation: 163
I recently RESET customizer setting with wp customizer plugin, did this on purpose to know certain error theme users would get on a fresh install of the theme, and I found out that on the customizer interface everything works well but when I actually load my design, I get a total different result.
Here is what it looks like
Blog result after customizer resets
Here is the code i am using to change in settings from the customizer.php option ( dont think there is anything wrong with my settings pattern)
$wp_customize->add_setting(
'sq_hide_blog_info',
array(
'default' => true,
)
);
$wp_customize->add_control(
new Toggle_Checkbox_Custom_control(
$wp_customize,
'sq_hide_blog_ctr',
array(
'description' => __( 'Display Site name / Description' ),
'label' => __( 'Check here' ),
'section' => 'custom_footer_text',
'settings' => 'sq_hide_blog_info',
'type' => 'checkbox',
'section' => 'sq_nav_design'
)
)
);
here is what i am using to change options in the actual code.
example
<?php if(get_theme_mod('nav_type_select') == 1): ?>
<?php include get_template_directory() . '/template-parts/header/header-1.php'?>
<?php else: ?>
<?php include get_template_directory() . '/template-parts/header/header-2.php'?>
<?php endif; ?>
The above settings is a check box, and default output set to 1, and I meant that, if nav 1 is selected then output it else, output nav 2 as default, if nav 1, is not selected then output nav 2, things was working fine until i reset the customizer default, which i guess would pull same error when i get a fresh install.
i know the settings in the code doesn't tally with the one in the customizer.php just using this for reference purpose.
i am solely depending on the customizer default to output value in the theme, with no fallback .
my instinct is telling me that the issue is from the way i placed my if statement , cause i used that pattern through out my code.
Thanks in advance, i would truly appreciate your help.
To be clear: i need help in , checking if my if else pattern is correct, if yes, then any work around to make the customizer actually update the new settings in the default page.
Upvotes: 0
Views: 272
Reputation: 163
i was able to fix this
this worked for me, even if all settings was refreshed
if ( get_theme_mod('my_banner_setting', 1) == 1 ) {
// proceed
}
Upvotes: 1
Reputation: 41
You need to pass Theme modification name in get_theme_mod()
Try this snippet
<?php if( checked( get_theme_mod( 'sq_hide_blog_info', true ), true, false ) ) : ?>
<?php include get_template_directory() . '/template-parts/header/header-1.php'?>
<?php else : ?>
<?php include get_template_directory() . '/template-parts/header/header-2.php'?>
<?php endif; ?>
Upvotes: 0