GET_THEME_MOD不返回输出

时间:2015-04-24 作者:andy

我搞不懂为什么这没有显示任何东西。该选项出现在“外观-自定义”菜单中,我使用以下方式输入设置和显示:-

<?php get_theme_mod( \'twitter\' ); ?>
<?php get_theme_mod( \'facebook\' ); ?>
但什么都没有出来。为什么?

function debut_theme_customizer( $wp_customize ) {

// Add Social Media Section
$wp_customize->add_section( \'social-media\' , array(
    \'title\' => __( \'Social Media\', \'_s\' ),
    \'priority\' => 30,
    \'description\' => __( \'Enter the URL to your account for each service for the icon to appear in the header.\', \'_s\' )
) );

// Add Twitter Setting
$wp_customize->add_setting( \'twitter\' , array( \'default\' => \'\' ));
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, \'twitter\', array(
    \'label\' => __( \'Twitter\', \'_s\' ),
    \'section\' => \'social-media\',
    \'settings\' => \'twitter\',
) ) );

$wp_customize->add_setting( \'facebook\' , array( \'default\' => \'\' ));
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, \'facebook\', array(
   \'label\' => __( \'Facebook\', \'_s\' ),
    \'section\' => \'social-media\',
    \'settings\' => \'facebook\',
) ) );



}
add_action(\'customize_register\', \'debut_theme_customizer\');

1 个回复
SO网友:Behzad

你应该这样做echo 输出:

<?php echo get_theme_mod( \'twitter\' ); ?>
<?php echo get_theme_mod( \'facebook\' ); ?>

结束

相关推荐