• Resolved David Gard

    (@duck_boy)


    I have added support for custom headers on my website, but the Theme Customisation options do not show up.

    I have the page under Appearance -> Header, but if I click Appearance -> Customise I do not get the Header Image section, thus I cannot carryout live previews. Can someone please help me with this?

    Thanks,

    add_action('after_setup_theme', 'setup_theme_support');
    function setup_theme_support(){
    
    	$args = array(
    		'default-image' => get_template_directory_uri().'/images/header.png',
    		'header-text'   => false,
    		'height'        => 78,
    		'uploads'       => true,
    		'width'         => 202
    	);
    	add_theme_support('custom-header', $args);
    
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • I assume that the above is part of a function called using a hook like after_setup_theme, yes?

    Thread Starter David Gard

    (@duck_boy)

    Yes it is, I just got too over-eager on my cutting! Will amend.

    I do add some of my own customisation settings, although none that use the header_image section, and I when I output $wp_customize I can see that the header_image setting is listed and includes my default image.

    It has the parameter [theme_supports] => custom-header, which has obviously been added as I get the page Appearance -> Header.

    Thanks.

    Could we see the complete function code?

    Thread Starter David Gard

    (@duck_boy)

    Of course. I also include the action/function to add theme support for custom headers in this file, but I’ve not duplicated it as it is posted in my original question.

    Thanks.

    /**
     * Add the JS for the live preview
     */
    add_action('customize_preview_init', 'customiser_live_preview');
    function customiser_live_preview(){
    	wp_enqueue_script('theme-customiser', get_template_directory_uri().'/admin/js/customise.js', array( 'jquery','customize-preview' ), '', true);
    }
    
    /**
     * Add custom controls to the theme customiser
     */
    add_action('customize_register', 'register_costomisation_controls');
    function register_costomisation_controls($wp_customize){
    
    	$wp_customize->add_section('footer_section' , array(
    		'title'		=> __('Footer', 'dd_theme'),
    		'priority'	=> 1010
    	));
    
    	$wp_customize->add_setting('footer_background_colour' ,array(
    		'default'	=> '#CFCFCF',
    		'transport'	=> 'postMessage'
    	));
    	$wp_customize->add_setting('footer_text' ,array(
    		'default'	=> '',
    		'transport'	=> 'refresh'
    	));
    
    	$wp_customize->add_control(
    		new WP_Customize_Color_Control(
    			$wp_customize,
    			'footer_background_colour',
    			array(
    				'label'		=> __('Background Colour', 'dd_theme'),
    				'section'	=> 'footer_section',
    				'settings'	=> 'footer_background_colour'
    			)
    		)
    	);
    	$wp_customize->add_control(
    		new Customize_Textarea_Control(
    			$wp_customize,
    			'footer_text',
    			array(
    				'label'		=> __('Text', 'dd_theme'),
    				'section'	=> 'footer_section',
    				'settings'	=> 'footer_text'
    			)
    		)
    	);
    
    }
    
    /**
     * Output the relevant styles for customised settings in the header
     */
    add_action('wp_head', 'output_costomisation_css');
    function output_costomisation_css(){
    ?>
    	<style type="text/css">
    		#footer-full-width{
    			background-color: <?php echo get_theme_mod('footer_background_colour'); ?>;
    		}
    	</style>
    <?php
    }
    
    /**
     * Custom control class for including a textarea in the theme customiser
     */
    if(class_exists('WP_Customize_Control')){
    class Customize_Textarea_Control extends WP_Customize_Control{
    
        public $type = 'textarea';
    
        public function render_content(){
    ?>
    		<label>
    			<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
    			<textarea rows="5" style="width:100%;" <?php $this->link(); ?>><?php echo esc_textarea( $this->value() ); ?></textarea>
    		</label>
    <?php
    	}
    }
    }

    I do add some of my own customisation settings

    What happens if you remove these and pare everything down to the absolute minimum?

    Thread Starter David Gard

    (@duck_boy)

    Ah, never mind, I’ve just figured it out completely by accident!

    It seems that you must have uploaded at least one image via Appearance -> Headers for the section to appear in Appearance -> Customise. As I was using a default from my theme and had no uploaded images, the section was hidden.

    Thanks for you time though, help is always appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘'Header Image' section missing from 'Appearance -> Customise'’ is closed to new replies.