Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have an option in my WordPress theme in which I can select +600 Google Fonts in a combobox.

I added this option using a huge array containing them.

But the problem is that I have to save the options and reload the page to see the Font. I would like to see it in the options page directly, if it's possible, in the combobox itself.

I'm using the API Settings of WordPress, and this is the code of my combobox:

<div class="op-field">
  <div class="op-left">
    <p class="op-title"><?php if (isset($value['name'])) { echo $value['name']; } ?></p>
  <div class="op-right">
    <select style="width:240px;" name="<?php if (isset($value['id'])) { echo $value['id']; } ?>" id="<?php if (isset($value['id'])) { echo $value['id']; } ?>"><?php foreach ($value['options'] as $option) { ?>
      <option<?php if (get_option($value['id'], $value['std']) == $option) { echo ' selected="selected"'; } ?>><?php echo esc_attr($option); ?></option><?php } ?>
  <p><label><?php if (isset($value['desc'])) { echo $value['desc']; } ?></label></p>
</div><hr class="clear" />

I need ideas about how to do this. I'm adding the following line in the SELECT:

style="font-family:<?php echo esc_attr($option); ?>"

But it's not working at all.

UPDATE: Like this example: http://cdn.elegantthemes.com/blog/wp-content/uploads/2013/05/font_preview.jpg

share|improve this question
In one way or another, for example via jQuery/Ajax, you have to make the functionality dynamic, otherwise a page refresh will be needed. –  ialocin Apr 5 '14 at 10:34

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.