customizer-library
customizer-library copied to clipboard
Get default helper function not displaying default
I'm having some trouble working out why the default helper function isn't returning my option defaults. Example usage:
$options['home-posts-section-title'] = array(
'id' => 'home-posts-section-title',
'label' => __( 'Section Title', 'themename' ),
'section' => $section,
'type' => 'textarea',
'default' => __( 'Latest News', 'themename' ),
'transport' => 'postMessage'
);
The setting is being called like this:
echo esc_attr( get_theme_mod( 'home-posts-section-title', customizer_library_get_default( 'home-posts-section-title' ) ) );
The default displays in the customizer screen but not on the live site.
I've sorted this out. I had a conditional without also including the helper function. This works (it can be cleaned up but just for example).
if ( get_theme_mod( 'home_posts_section_title', customizer_library_get_default( 'home_posts_section_title' ) ) ) {
echo esc_attr( get_theme_mod( 'home_posts_section_title', customizer_library_get_default( 'home_posts_section_title' ) ) );
}
Please close this issue. :)