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'm trying to get current styles from a live preview when Customizer is loaded to set them in my controls. How can I do that?

I was trying in this way:

$('#customize-preview iframe').contents().find('body').css('font-size');

but it returns 'undefined', so as I think contents() loads only DOM without any styles.

Is there any suitable function in WP Customizer which I can use to get style values and set them in my controls?

Example: I've created control to change font-size and I used Slider UI to achieve it. Here is my problem. When I open Customizer, the slider is setted to 0. It doesn't make any sense, because font-size (i.e. for body) on my website is 13px, so the slider should also be setted to 13, not 0.

To solve my problem I would like to get the current body font-size from my website and set it to the slider. I don't know, maybe there is a better solution. I hope it's clear now.

share|improve this question
Have you seen the WP Theme Customizer API? – kaiser Nov 4 '13 at 12:40
Yes, there isn't any function in the documentation to achieve it. – Marek Zygmunt Nov 4 '13 at 12:56
Then please edit your question and add more detail about what you want to achieve. So far it's very vague and (at least to me) very unclear. – kaiser Nov 4 '13 at 13:28
I've just added the example. – Marek Zygmunt Nov 4 '13 at 13:57
As I think I can use wp.customize.Messenger. If somebody knows how? gyazo.com/07d11604f111fe645a90ada930637976 – Marek Zygmunt Nov 5 '13 at 14:59

Your Answer


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

Browse other questions tagged or ask your own question.