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

In our development process we have several branches of the same theme for each developer. Theme branches live in different directory names, so when doing get_theme_mod(), get_option("stylesheet") can return different values, should we for some reason (customer demo) be forced to activate another theme branch besides "master".

This makes us have to reconfigure menus, widgets, customizer mods etc etc.

In our case, it's very rare that theme mods need to be different across branches, so I would like get_theme_mod() to always access the same mods array.

The obvious solution seems to be making "pre_option_stylesheet" filter as a standard part of the theme codebase, but I am not sure if it may have any unintended side effects. Grepping around, looks like this option is almost exclusively used in a few places in wp-includes/theme.php.

Q: Is "pre_option_stylesheet" filter the way to go here? Or can you think of something else?

share|improve this question

Filter "theme_mod_$name" in a separate plugin:

add_filter( 'theme_mod_very_special', function() {
    return 'forced value';

To replace the complete theme mods, filter pre_get_option_theme_mods_$theme_name and return an array. You have to register that filter for each theme name.

share|improve this answer
I am not sure I follow. This looks like hardcoding a single value, while I would want to re-use the whole array. Looking at get_theme_mod(), I would rather expect some filter that lets me override $mods in get_theme_mods(). – lkraav May 28 '13 at 22:16
@lkraav See my update. – toscho May 28 '13 at 22:20
Hmmm good thinking going a level higher with the pre_get_option filter, not sure why I didn't think of that (answer: past midnight!). I'll put together some example code and let's possibly edit the answer then if you like it. – lkraav May 28 '13 at 22:34

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.