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?
- The the_post_thumbnail without srcset?
- after_setup_theme always runs
- WordPress API Menu/Submenu Order
- What is the difference between wp_register_sidebar_widget and register_widget?
- How to enqueue script if widget is displayed on page?
- What WP folder can I use to write files to?
- Why I can’t add a CSS style in this WordPress theme?
- Display a different theme for not logged-in users
- Best practice (forward compatibility) for theme options
- Add colors to existing color palette without replacing it
- Single Page WordPress Theme – Using page templates
- How do I get gallery thumbnail URL and change the default thumbnail size?
- How to Modify a Widgets UL and/or LI Classes
- Returning Variables back into a template
- new theme permissions don’t allow me to edit
- Upgrading a custom theme through the Dashboard
- Get list of months with posts
- Cannot get full thumbnail size using the_post_thumbnail
- Version control for both Vagrant config and themes being developed [closed]
- Is there a way to activate different theme for specified users? [closed]
- how can I remove the sidebar from my wp homepage [closed]
- How to determine if post has widget content?
- Does any theme support child theme?
- How do I save a wordpress theme’s files and install them on another site?
- “add_theme_support” for custom footer color?
- Set multiple templates per post
- How to add infinite scroll?
- get_option in header.php not returning value from customizer
- Internal error 500 accessing Theme > Customize
- Save Widget State Between Theme Swaps?
- Theme Development: Starter Content after hook
- Change locale by detecting viewer’s browser language setting and let them choose prefered language after
- Why is it needed to enqueue parent stylesheet in child theme?
- Is there any WordPress theme for Self Storagae just like Spacer [closed]
- Customizer: save setting/control content to post/page
- WordPress Unite Theme: Footer isn’t sticking [closed]
- Is accessing theme and using customizer GPL distribution?
- How to enqueue javascript for WP Customize options sidebar?
- WordPress 500 Internal server error when activating custom theme [closed]
- How do i place same widgets multiple time by default on theme activation?
- Customize how a WordPress theme looks like in the Theme Selector
- How to set a page as homepage in stead of the newspages?
- WordPress Theme Validator?
- If you were to start using a WordPress framework today, which one would you use? [closed]
- Register sidebar ‘before’ and ‘after’ html as div rather than li tags
- Template for landing pages
- Is it possible to have a theme that uses only one single page?
- underscores use of the article element on the page template
- Plugin does not work in custom theme
- html5-reset theme does not show the image [closed]
- How to include a file only on dashboard widgets page?
- Adding a gallery to my first theme
- What exactly is “wordpress theming”? [closed]
- Valid SQL query not returning results
- Unable to add widgets to sidebars in custom theme
- Change Image Sizes for Mobile Theme
- Recommended sidebar / content widths
- Converting a theme to a child theme in a network
- What is the difference between Twenty eleven & roots framework?
- Is there a list of default generated Gutenberg block CSS? Unable to align video blocks
- How to change listing type permlink?
- Adding popup support to the theme
- Calling a WP Plugin Function’s Variable in Theme Template [duplicate]
- How to make updatable custom WordPress theme?
- How can I access variables from theme in child theme? [closed]
- Local variable name in setup_postdata()
- Creating a Single Page Theme correctly
- Is it possible to echo a woocommerce prouct attribute discription?
- Child theme menu not appearing in Twenty Seventeen
- How do I remove header/page-title image in farvis theme? [closed]
- How to link post image to post link?
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- On wordpress, how do i require specific dimensions from user uploads only
- WordPress Theme Developments – Start from another theme
- Slider should be display in home template [closed]
- Modify comments_popup_link output
- Can you create a custom page with content in the center already defined?
- How to migrate the menu from the site on my own theme in WordPress?
- RSS feed url showing page not found. How to solve it?
- How to convert that page to a wordpress template? [closed]
- Toolbox theme using printif statement – help needed understanding code block
- php file child theme directory not overriding parent theme php file [duplicate]
- How to Create a Multi Purpose Theme?
- Custom Single Page Portfolio Theme [closed]
- What is the point of using the front-page.php template? [closed]