customizer-library icon indicating copy to clipboard operation
customizer-library copied to clipboard

Get default helper function not displaying default

Open jamigibbs opened this issue 10 years ago • 1 comments

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.

jamigibbs avatar Aug 05 '15 11:08 jamigibbs

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. :)

jamigibbs avatar Aug 05 '15 12:08 jamigibbs