Home Forums General Issues Color Picker Palette(s) more than one


Color Picker Palette(s) more than one

  • I’m creating a multiple Color Pickers to help my users pick colors, but I want to offer theme custom palettes which I’ve been able to do using this..

    However I want two different color pickers to have two different palettes. The code I currently have makes one palette apply to both the color pickers. See the two images attached.

    How can I make one palette apply to color_primary and another palette apply to color_secondary?

    Here is the code I have so far – I’m using WordPress functions.php to enter the code.

    function my_acf_color_picker_palette_primary() {
    <script type="text/javascript">
    (function($) {
    	acf.add_filter('color_picker_args', function( args, $field ){
    	// find a specific field
    	var $field = $('color_primary');	
    	// do something to args
    	args.palettes = ['#5ee8bf', '#2f353e', '#f55e4f']
    	// return
    	return args;
    add_action('acf/input/admin_footer', 'my_acf_color_picker_palette_primary');*
  • The value in $field passed to your filter should have information about the field. I’m not sure what the index is but this information should include the field key console.log($field);. You should test this value and might be able to use different palettes for different fields (but I’m not sure about any of this)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.