Last active
December 22, 2019 14:22
-
-
Save ivo-ivanov/a9c6848aceb62d5f76246c0a697bb63b to your computer and use it in GitHub Desktop.
Custom color swatches filter for ACF Color field. #wordpress #acf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function custom_acf_swatches() { | |
| ?> | |
| <script type="text/javascript"> | |
| (function($) { | |
| acf.add_filter('color_picker_args', function( args, $field ){ | |
| // add the hexadecimal codes here for the colors you want to appear as swatches | |
| args.palettes = ['#2facbf', '#474747']; | |
| // return colors | |
| return args; | |
| }); | |
| })(jQuery); | |
| </script> | |
| <?php | |
| } | |
| add_action('acf/input/admin_footer', 'custom_acf_swatches'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment