• quinox

    (@quinox)


    Hi,

    I’m struggling for 2 days now to extend the default theme customizer in my theme. I’m using the underscore_me basic theme and extend it with bootstrap.

    In my function.php I have the hook:
    require get_template_directory() . '/inc/customizer.php';
    This hook the customizer.php file.

    In this file I see the code:

    function webinweb_design_customize_register( $wp_customize ) {
    	$wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
    	$wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
    	$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
    
    add_action( 'customize_register', 'webinweb_design_customize_register' );
    
    /**
     * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
     */
    function webinweb_design_customize_preview_js() {
    	wp_enqueue_script( 'webinweb_design_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true );
    }
    add_action( 'customize_preview_init', 'webinweb_design_customize_preview_js' );

    I’ve read alot those 2 days howto create new action and settings for customizer, but it seems my theme doesn’t like this.

    I added this piece of code to my customizer.php file:

    /*************************************************************
     Background color
    **************************************************************/
    $wp_customize->add_section(
          'background_section',
          array(
              'title' => 'Background color',
              'description' => 'This is a settings section.',
              'priority' => 35,
          )
      );
    
    //add_action( 'customize_register', 'background_customizer' );
    
    $wp_customize->add_setting(
        'color-setting',
        array(
            'default' => '#000000',
            'sanitize_callback' => 'sanitize_hex_color',
        )
    );
    
    $wp_customize->add_control(
        new WP_Customize_Color_Control(
            $wp_customize,
            'color-setting',
            array(
                'label' => 'Background color',
                'section' => 'background_section',
                'settings' => 'color-setting',
            )
        )
    );

    I can see the new setting in wp-admin now. I can select colors, but there is no preview and the settings aren’t applied.

    Hope someone can help me with this.

    regards,

    Roland

  • The topic ‘theme customizer’ is closed to new replies.