The following worked for me. I using class attribute instead of ID to match multiple color pickers.
<script type="text/javascript">
jQuery(document).ready(function($) {
jQuery('.color-picker').on('focus', function(){
var parent = jQuery(this).parent();
jQuery(this).wpColorPicker()
parent.find('.wp-color-result').click();
});
});
</script>
My Widget form is set up like :
<p>
<label for="<?php echo $this->get_field_id( 'font_color' ); ?>" style="display:block;"><?php _e( 'Font Color:' ); ?></label>
<input class="widefat color-picker" id="<?php echo $this->get_field_id( 'font_color' ); ?>" name="<?php echo $this->get_field_name( 'font_color' ); ?>" type="text" value="<?php echo esc_attr( $font_color ); ?>" />
</p>
Related Posts:
- Should I use set_transient or update_option?
- register_sidebar ignores ‘id’ and ‘class’
- use add_action(‘wp_head’) in a widget for generating dynamic CSS styles
- Registering Sidebars and Sidebar Widgets. Sidebar Widgets Not Displaying
- How do I display the “Archives” widget layout (sidebar) in WordPress by ‘year’ then by ‘months’?
- Is it a good idea to make whole theme widgetized?
- How i can get widgets areas working in customizer?
- Cutomize Colors utility: How to add more configurable colors to a theme
- Widget Option is Missing
- Is it acceptable for a WordPress theme to not accept widgets?
- How can I hard code my sidebar?
- How to hide custom sidebar on mobile
- Text widget is placing everything side by side. I want to post it above
- Best strategy for providing theme options using customizer
- What’s the policy for building a theme that doesn’t support widgets/menus?
- Sizing screenshot.png without losing aspect ratio
- How to add CSS class to custom logo?
- How to add custom css file in theme?
- theme path in javascript file
- get_template_part vs action hooks in themes
- Can I create my own “Recent Posts” widget or customize the existing one?
- The the_post_thumbnail without srcset?
- The proper way to include/require PHP files in WordPress
- after_setup_theme always runs
- Do I actually need to link my theme’s style.css in the theme files
- How to store widget fields data as an array?
- Using classes instead of global functions in functions.php
- WordPress API Menu/Submenu Order
- Adding a div to wrap widget content after the widget title
- How to insert a logo in the header?
- How to move page template files like page-{slug}.php to a sub-directory?
- What is the difference between wp_register_sidebar_widget and register_widget?
- How do register_sidebar() and get_sidebar() work together?
- CSS classes for theme
- How to enqueue script if widget is displayed on page?
- Add custom classes to anchor in wp_nav_menu
- How to remove search bar from a wordpress theme? [closed]
- Should `get_template_directory_uri()` be escaped?
- Get url of thumbnail from the media uploader
- My child theme doesn’t work Error: “The parent theme is missing. Please install your parent theme”
- How To Add New Option Types To Option Tree?
- WP 3.4 – what action/hook is called when theme customisation is saved?
- What WP folder can I use to write files to?
- Are the WordPress Core CSS styles really all nessesary?
- Call dynamic_sidebar but include/exclude named widgets?
- Add a dropdown to theme customizer
- Why doesn’t default WordPress page view use force_balance_tags?
- Page template in two level deep folder
- HowTo: Add Class to Sidebar Widget List-Items
- Theme Customizer : how to create multiple-level panel
- Why I can’t add a CSS style in this WordPress theme?
- Theme file for all pages that are a child of a specific page
- Allow Shortcode in Theme Customizer
- Where to post/upload the new theme for WordPress theme repository
- How to add Color Picker in Theme Options for the following?
- Setting multiple default background images?
- Template for individual post designs
- How to make a theme with more than one CSS file?
- Is it good to rename theme folder downloaded from WordPress.org?
- Best practice way to implement custom sections into a WordPress theme
- Editing the custom background CSS
- What is the problem if I use CDN in my WordPress parent theme(built using bootstrap)?
- How wp_cache is supposed to work, and does it help with performance?
- What, specifically, should be included in theme_name_setup()?
- How to get gallery images?
- Is it possible to use line break in theme description?
- Is the theme customizer slowing down my site?
- How can I get wp_head() as a string instead of echoing it?
- Display a different theme for not logged-in users
- Best practice (forward compatibility) for theme options
- Automatic Updates For Private And Commercial Themes?
- Add colors to existing color palette without replacing it
- Child Theme not loading parent CSS
- What can I hook into after_setup_theme?
- Where do I find the functions triggered within a hook?
- What does “Do not deregister the jquery script in the administration area” mean?
- How to determine the current widget’s parent container (sidebar widget id)
- What is the best book to learn how to make themes for wordpress?
- Grab the first paragraph of each post
- How to get the registered sidebar’s name by its id?
- Adding widgets programatically: how to avoid collisions?
- Add class to before_widget for all widgets with a dropdown and a counter
- add_image_size is scaling, even though crop is set to true
- Use of undefined constant FS_CHMOD_DIR – assumed ‘FS_CHMOD_DIR’
- Enabling Widgets By Default in Custom Theme Development
- How to show next Post Thumbnail image in WordPress using current post id
- Symlink a directory to wp-content/themes
- Single Page WordPress Theme – Using page templates
- Pushing updates to your premium theme
- File included into functions.php via require_once() won’t echo?
- Where can I find a good reviewed collection of Twenty Ten child themes?
- How to check if post has any tag?
- Adding inline styles from a widget
- What are WooCommerce starter themes? [closed]
- How do I get gallery thumbnail URL and change the default thumbnail size?
- modify a output of a widget
- Front End Post Submit Form
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Context aware widgets. My work in progress
- How to determine which sidebar the widget has been added to, via widget admin?