0

I am creating WordPress themes, when i install theme on another site / domain, the default values added under wp_customizer do not apply for the first time when theme is just installed. When i go to customizer all the default values gets applied and appear to working. but if i close customizer without any changes published, no default values are applied. I need to again go to customizer clear default values in the customizer setting and set same default value and publish. Then it appears.

I want to ask if there is any function to apply default values of customizer when theme is installed for the first time.

Something like set all theme mods to default values..

0

No, there is no automatic way to save all defaults, and for good reason. It avoids cluttering the database with unnecessary values, and allows themes to actually change their defaults down the line. Instead of trying to save all defaults, just change all your calls to get_theme_mod to include the default value as the 2nd parameter. That is how it is intended to be used :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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