[Support request] Can't change color palette with filter

Home Forums Support [Support request] Can't change color palette with filter

Home Forums Support Can't change color palette with filter

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #884412
    Silvio

    Hi,

    I added this code in the function.php of my child theme (blank, just installed)

    add_filter( 'generate_default_color_palettes', 'tu_custom_color_palettes' );
    function tu_custom_color_palettes( $palettes ) {
    	$palettes = array(
    		'#000000',
    		'#FFFFFF',
    		'#20ec73',
    		'#575757',
    		'#222222',
    		'#1e72bd',
    		'#8E44AD',
    		'#00CC77',
    	);
    	
    	return $palettes;
    }

    But I can’t see custom color codes in my palette.

    #884569
    Tom
    Lead Developer
    Lead Developer

    That looks good – those colors aren’t showing up in the Customizer when you open a color picker?

    Can you try this?:

    add_action( 'wp', function() {
        add_filter( 'generate_default_color_palettes', function() {
            return array(
                '#000000',
                '#FFFFFF',
                '#20ec73',
                '#575757',
                '#222222',
                '#1e72bd',
                '#8E44AD',
                '#00CC77',
            );
        } );
    } );
    #884585
    Silvio

    yes, colors in the customizer didn’t change. and unfortunately, neither trying with the code you posted.

    I am running it on MAMP, and I even have tried to stop and restart the servers. And change the browser from Chrome to Safari.

    #884807
    Silvio

    additionally, I created a clean installation in MAMP with the last version of everything, and no one of this codes works ๐Ÿ™

    #884810
    Tom
    Lead Developer
    Lead Developer

    I just tried the first function you shared and here’s what I see: http://prntscr.com/nivzu9

    Looks like it’s working?

    How are you adding the function?

    #884969
    Silvio

    are you using MAMP?

    I just copy and pasted the function in the function.php of the child theme

    #885696
    Tom
    Lead Developer
    Lead Developer

    I’m using XAMPP, but it shouldn’t matter. Any other servers/sites you can test on?

    #1007498
    Klaus

    First solution by Silvio worked fine for me. Thx Klaus

    #1007854
    Leo
    Staff
    Customer Support

    Glad you’ve found the post ๐Ÿ™‚

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.