WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need your help as I am stuck and Google does not return anything, so I must be doing something obiusly wrong here, I just don't know what.

Basically, I need color input in one of my custom post types meta and I am trying to use a new WordPress 3.5 colorpicker for that. I could simply find another script and use it, but if it's already bundled with WP, that's what I should use.

So anyway, this is what I have done:

I have this input field in custom metabox:

<input name="mv_cr_section_color" type="text" id="mv_cr_section_color" value="<?php echo $sections_color; ?>" data-default-color="#ffffff">

I have this piece for enqueueing the script needed:

wp_enqueue_script( 'wp-color-picker' );

and finally I have this custom js:


wrapped in .ready()

Result is this: Input field gets hidden (it gets display: none inline urle applied to it), if I uncheck that (using Google Chrome), when I click the field nothing happens (:focus should trigger colorpicker). If I then unhide colorpicker (it is spawned, I see it in source) I can use it and it functions normally, default color also works well but I just can't find the reason why field gets hidden and why it does not open colorpicker on focus.

Anyone have any idea, I am really ... about this :)


EDIT: Just the note, no error in console.

share|improve this question
up vote 2 down vote accepted

I tried the following and it works:

function wpse_80236_Colorpicker(){ 
    // you forgot this probably it's the bundled CSS
    wp_enqueue_style( 'wp-color-picker');
    wp_enqueue_script( 'wp-color-picker');

add_action('admin_enqueue_scripts', 'wpse_80236_Colorpicker');

Then your input:

<input name="mv_cr_section_color" type="text" id="mv_cr_section_color" value="#ffffff" data-default-color="#ffffff">

Then the following js:

share|improve this answer
I have to because in that variable I hold the color saved in post_meta, how else would I remeber user's choice? I did check out that website and also a few other exact tutorials, also a sample plugin maed but nothing helped me realize where I have mistaken. – OriginalEXE Jan 11 '13 at 22:58
The suggestion was to debug it, to see if it works or not. – Wyck Jan 11 '13 at 22:59
Ok, just tested without the php part (clean html input field) and still the same thing happens. – OriginalEXE Jan 11 '13 at 23:02
OK I think I know what's wrong gimme 1 min – Wyck Jan 11 '13 at 23:04
did you try to also wp_enqueue_style( 'wp-color-picker' ); – Wyck Jan 11 '13 at 23:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.