admin管理员组文章数量:1405895
Have made a custom section that displays in the Customizer. It has controls for image upload and text inputs for both the heading and its link. I want to be able to show a default heading and link inside the inputs, before users enter their own content. Have added 'default' to both setting and get_theme_mod, but can't get it to show.
Here is heading and link input settings and controls, along with image of customizer showing no defaults inside the input controls:
// Add section, settings and controls for sids (sids stands for Single Item Display Section)
// Add the section for sids
$wp_customize->add_section( 'ccshoes_sids_section' , array(
'title' => __( 'Single Item Display Section', 'ccshoes' ),
'description' => __( '2 column section for displaying single item and text' ),
) );
// Add the setting for sids heading text
$wp_customize->add_setting( 'ccshoes_sids_text_input', array (
'default' => __( 'NEW ARRIVALS', 'ccshoes' ),
'sanitize_callback' => 'sanitize_text'
));
// Add the control for sids heading text
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'ccshoes_sids_text_input_control',
array(
'label' => __( 'Enter your heading, e.g: NEW ARRIVALS', 'ccshoes' ),
'section' => 'ccshoes_sids_section',
'settings' => 'ccshoes_sids_text_input',
)));
// Add the setting for sids heading/image link
$wp_customize->add_setting( 'ccshoes_sids_link_input', array (
'default' => __( '/product-category/new-arrivals/', 'ccshoes' )
));
// Add the control for sids heading/image link
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'ccshoes_sids_link_input_control',
array(
'label' => __( 'Enter your heading/image link', 'ccshoes' ),
'section' => 'ccshoes_sids_section',
'settings' => 'ccshoes_sids_link_input'
)));
// Output sids
function ccshoes_display_sids() {
$sids_image = get_theme_mod( 'ccshoes_sids_img_upload' );
$sids_heading = get_theme_mod( 'ccshoes_sids_text_input', 'NEW ARRIVALS' );
$sids_link = get_theme_mod( 'ccshoes_sids_link_input', '/product-category/new-arrivals/');
// Output sids ?>
<div class="row">
<div class="col-1">
<a href="<?php echo $sids_link; ?>"><h1><?php echo $sids_heading; ?></h1></a>
</div>
<div class="col-2">
<a href="<?php echo $sids_link; ?>"><img src="<?php echo $sids_image; ?>"></a>
</div>
</div>
<?php }
add_action( 'ccshoes_sids_section', 'ccshoes_display_sids' );
本文标签: theme developmentHow do i make a custom section39s setting display the default value in Customizer
版权声明:本文标题:theme development - How do i make a custom section's setting display the default value in Customizer? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744946392a2633807.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论