In my Customizer, I have a checkbox to "Display Title". I want the title to display by default (which it is in the Customizer) but the Customizer settings need to be saved in order for it to display on the live site. I would like it to display without having to save the settings first.
This is the code I have in my template file:
<?php if( get_theme_mod( 'display_header_image_title' ) == '1') { ?>
<h1 id="header-image-title"><?php echo get_theme_mod( 'header_image_title' , __( 'default text', 'myTheme' )); ?></h1>
<?php } ?>
This is the code I have in my customizer.php file:
// Title
$wp_customize->add_setting( 'header_image_title', array(
'default' => __('Title','myTheme'),
'transport' => 'postMessage'
) );
$wp_customize->add_control( 'header_image_title', array(
'label' => __('Title','myTheme'),
'type' => 'text'
) );
// Display Title
$wp_customize->add_setting( 'display_header_image_title', array(
'default' => true,
'transport' => 'postMessage'
) );
$wp_customize->add_control( 'display_header_image_title', array(
'label' => __('Display Title','myTheme'),
'type' => 'checkbox'
) );
I suspect this line needs to be edited in the template file:
<?php if( get_theme_mod( 'display_header_image_title' ) == '1') { ?>