I've been following this great tutorial (http://wp.tutsplus.com/tutorials/theme-development/digging-into-the-theme-customizer-overview/) and now I have set the Theme customizer.

As far as I understand the settings I assign in the customizer are saved in the database every time the user "saves" in the theme customizer page. Which means that after activating the theme for the first time and before going to the customizer, the settings are not saved.

My question is, How can I save the settings just after the user activates the theme? (the $wp_customize->add_setting default value)

Pd. I've been looking for some time, and got this hooks: "after_setup_theme", "switch_theme", but I cant figure out how to do it.

Edit: The "duplicate question" answers how to provide a fallback when there is no setting available. Although it might be a workaround, I would like to know how to save (register) the settings when activating the theme.

  • Read the answer to the duplicate question till the very end - it does provide a permanent solution. Oct 6, 2013 at 10:59
  • Thanks, Its geting confusing for me on how to do what suggested in the duplicate (add_option) with theme customizer. Anyway I gave up and Im using the fallback solution.
    – Alvaro
    Oct 6, 2013 at 11:33

1 Answer 1


You need only use the default value on the wp_customize and that is all

$wp_customize->add_setting('mytextoption', array(
    'default'        => 'defaultvalue',
    'capability'     => 'edit_theme_options',
    'type'           => 'option',

replace defaultvalue for the value you want, and when the user activate the theme this line will register the default value on the DB only when not exist on the DB

  • So you mean the first register doesnt happen when pressing save in the customizer for the first time, but when activating the theme. right?
    – Alvaro
    Oct 6, 2013 at 8:58

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