• Hi, I am trying to add a Background Header Color control to the customizer

    My first question is it even possible?
    Ive searched for existing themes that have this and cant find any.
    Seems to me if you can change the main background color you should be able to change the header background color.

    Also searched out and gone through some customizer.php tutorials
    Im not at all good at php from scratch but can usually manage if i have some samples similiar to what I want to do.

    I managed to add a background header color control to the colors section that works in admin but doesnt do anything to the theme.

    1.) Is this even possible?
    2.) Just wondering if there is any reference guides showing all of the possible controls?
    3.)Or a tutorial or samples specificly with header background color control in the customizer.

    Thanks!

    • This topic was modified 3 years, 2 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter cambob

    (@cambob)

    This is the code I am using that I changed from the example here
    https://www.nosegraze.com/customizer-settings-wordpress-theme/

    /**
    	 * Section: Colours
    	 *
    	 * @param WP_Customize_Manager $wp_customize
    	 *
    	 * @access private
    	 * @since  1.0
    	 * @return void
    	 */
    	private function colours_section( $wp_customize ) {
    
    		/* Paragraph text */
    		$wp_customize->add_setting( 'header_background', array(
    			'default'           => '#444444',
    			'sanitize_callback' => 'sanitize_hex_color'
    		) );
    		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_background', array(
    			'label'    => esc_html__( 'Header Background Colour', 'twentytwelve-child' ),
    			'section'  => 'colors',
    			'settings' => 'header_background',
    			'priority' => 10
    		) ) );
    
    	}
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    If it helps, here’s my code that I used to add to the customizer:

    https://github.com/sterndata/2021-child/blob/trunk/functions.php#L8

    Thread Starter cambob

    (@cambob)

    Looks like you added to the functions file. tried adding to functions file didnt work. Also tried adding to customizer file but errors both cases.
    Thought I would try to tackle this but looks like its over my head.

    thanks anyway!

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I copied this from a tutorial somewhere. YOu could make this a plugin if you don’t want to edit the theme’s functions.php.

    Thread Starter cambob

    (@cambob)

    great I will take a look at that approach

    thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Customizer Header Background Color? Is it possible?’ is closed to new replies.