mercredi 1 novembre 2017

Header image on Custom Wordpress theme not showing up

I have created a custom theme in Wordpress, but my header image and header background color is not showing up. I even tried changing them in the customizer > header settings, but this doesn't work either. Also my custom-logo does not show up. I've tried reuploading all of my files onto FileZilla but nothing seems to be working. Any help would be greatly appreciated, thank you!

<?php

add_theme_support( 'custom-logo', array(

    'flex-width' => false,
    'header-selector' => '.site-title a',
    'default-image' => get_template_directory_uri() . '/assets/img/lake.svg',
) );

function custom_header_settings($wp_customize){

$wp_customize->add_section( 'header_settings' , array(
    'title'      => 'Header Settings',
    'priority'   => 30,
) );

$wp_customize->add_setting( 'background_color' , array(
    'default'    => '#dd8d13',
    'transport'  => 'refresh',
) );

$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'background_color', array(
    'label'      => 'Background Color',
    'section'    => 'header_settings',
    'settings'   => 'background_color',
) ) );

$wp_customize->add_setting( 'header_textcolor' , array(
    'default'   => '#ffffff',
    'transport' => 'refresh',
) ); 

$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_textcolor', array(
    'label'      => 'Title Color',
    'section'    => 'header_settings',
    'settings'   => 'header_textcolor'
) ) );

$wp_customize->add_setting( 'description_textcolor' , array(
    'default'   => '#ffffff',
    'transport' => 'refresh',
) ); 

$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'description_textcolor', array(
    'label'      => 'Description Color',
    'section'    => 'header_settings',
    'settings'   => 'description_textcolor'
) ) );

$wp_customize->add_setting( 'header_background_image', array(
    'default-image' => get_stylesheet_directory_uri() . '/assets/img/test.jpg',
));  

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'header_background_image', array(
'label'    => __( 'Upload Background Image', 'm1' ),
'section'  => 'header_settings',
'settings' => 'header_background_image',
) ) );

}

add_action( 'customize_register', 'custom_header_settings' );
?>

<?php

add_action( 'wp_head', 'cd_customizer_css');

function cd_customizer_css()
{

?>
<style type="text/css">
header {
background-color: <?php echo get_theme_mod('background_color', '#dd8d13'); ?>;
background-image: url(<?php echo get_theme_mod('header_background_image' , '/assets/img/test.jpg'); ?>);
}
header h1{ color: <?php echo get_theme_mod('header_textcolor', '#ffffff'); ?>;
}
header p{ color: <?php echo get_theme_mod('description_textcolor', '#ffffff'); ?>
}
</style>  

<?php 
}
?>




Aucun commentaire:

Enregistrer un commentaire