我在WordPress中创建了自己的主题,用户可以在其中设置自定义background-color
。
在XAMPP上本地运行时,我没有问题,但是当我将主题上传到Web服务器时,背景颜色消失了。当我进入Customizer选项卡时,背景颜色是正确的。网络服务器上的WordPress是全新安装。
似乎此行负责缺少颜色:
<?php echo get_theme_mod('info_bg_color'); ?>
它如何在页眉和页脚应为绿色的网络服务器上显示。 (Picture)
当我打开自定义程序选项卡时,颜色是正确的。 (Picture)
这只是代码的一部分。
请与我联系以获取完整网站。
任何人都可以帮助我吗?
/*
================================
Customize Appearance Options
================================
*/
function info_customize_register( $wp_customize ){
// Add setting
$wp_customize->add_setting('info_txt_color', array(
'default' => '#FFF',
'transport' => 'refresh',
));
$wp_customize->add_setting('info_bg_color', array(
'default' => '#287e43',
'transport' => 'refresh',
));
$wp_customize->add_setting('info_border_color', array(
'default' => '#ba2e25',
'transport' => 'refresh',
));
$wp_customize->add_setting( 'info_logo' );
$wp_customize->add_setting('text_setting', array(
'default' => 'Logo',
));
// Add section
$wp_customize->add_section('info_colors',array(
'title' => __('Farver','info'),
'priority' => 30,
));
$wp_customize->add_section('info_header_logo',array(
'title' => __('Logo','info'),
'priority' => 30,
'description' => 'Upload et logo som vil erstatte "Logo" teksten i din header',
));
$wp_customize->add_section('footer_settings_section', array(
'title' => 'Footer Text Section'
));
// Add control
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'info_txt_color_control', array(
'label' => __('Tekst Farve','info'),
'section' => 'info_colors',
'settings' => 'info_txt_color',
)));
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'info_bg_color_control', array(
'label' => __('Baggrunds Farve','info'),
'section' => 'info_colors',
'settings' => 'info_bg_color',
)));
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'info_border_color_control', array(
'label' => __('Border Farve','info'),
'section' => 'info_colors',
'settings' => 'info_border_color',
)));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'info_logo_control', array(
'label' => __( 'Logo', 'info' ),
'section' => 'info_header_logo',
'settings' => 'info_logo',
)));
$wp_customize->add_control('text_setting', array(
'label' => 'Logo Tekst',
'section' => 'info_header_logo',
'type' => 'textarea',
));
}
add_action( 'customize_register' , 'info_customize_register' );
/*
================================
Customize Appearance Options
================================
*/
function info_customize_css() { ?>
<style type="text/css">
header p, #digital-time {
color: <?php echo get_theme_mod('info_txt_color'); ?>;
}
header {
background-color: <?php echo get_theme_mod('info_bg_color'); ?>;
border-bottom: 4px solid <?php echo get_theme_mod('info_border_color'); ?>;
}
footer {
background-color: <?php echo get_theme_mod('info_bg_color'); ?>;
border-top: 4px solid <?php echo get_theme_mod('info_border_color'); ?>;
}
</style>
<?php }
add_action( 'wp_head' , 'info_customize_css' );