admin管理员组

文章数量:1424916

I can't work out why this isn't displaying anything. The option appears in the appearance - customise menu, I input my settings and display using:-

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

But nothing comes out. Why?

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');

I can't work out why this isn't displaying anything. The option appears in the appearance - customise menu, I input my settings and display using:-

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

But nothing comes out. Why?

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');
Share Improve this question asked Apr 24, 2015 at 18:48 andyandy 2,3598 gold badges25 silver badges34 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You should do echo output:

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

本文标签: theme developmentgetthememod returning no output