WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 am looking for a way to override the currently selected theme, preferably from within the wp_config.php file. I know you can override some wp_options settings in the config like

define('WP_HOME', 'http://someotherdomain.com');

This will override the 'home' option in the wp_options table. There is an option called 'current_theme' that stores the name of the currently selected theme. I'm wondering if there's a way to override this from the wp_config file and if so, will this actually change the theme.

I've tried

define('WP_CURRENT_THEME', 'someothertheme');

but it doesn't work.

I need to do this in our development environment because the database is shared among two developers. I need to be able to work on one theme, while the other developer works on another theme.

share|improve this question
Shared database == same database? Same domain? Same WordPress files? Based on what this switch should occur? – brasofilo Jul 19 '12 at 15:40
brasofilo, same database, different wordpress files. The code to switch the theme would just be temporary, in order to develop two different themes at the same time. One developer would use the database setting, the other would override the settings in wp_config. – joeljoeljoel Jul 19 '12 at 15:49
up vote 2 down vote accepted

Drop this in a plugin & activate. I should note this doesn't take into account things like child themes - it's purely for toggling which theme renders based on SOME_FLAG.

add_filter( 'stylesheet', 'switch_ma_theme' );
add_filter( 'template',   'switch_ma_theme' );

function switch_ma_theme()
    // Return the theme directory name
    return SOME_FLAG ? 'theme-1' : 'theme-2';
share|improve this answer
This worked for me. Thanks – joeljoeljoel Jul 19 '12 at 16:33

Another solution.

add_action( 'template_redirect' , 'thisismyurl_change_theme_manually' );

function thisismyurl_change_theme_manually() {
if ( 'twentyeleven' != get_stylesheet() && is_admin() )
switch_theme( 'twentyeleven', 'style.css' );

But if your using different WordPress installs why don't you just click "activate theme" in the admin?

ps. You can read more here: http://nacin.com/2012/03/29/page-templates-in-subdirectories-new-in-wordpress-3-4/

share|improve this answer
I'm using different WordPress installs but the same database. If one developer changes the theme in the admin, it will change for both developers – joeljoeljoel Jul 19 '12 at 16:09
You should not share a database, you're going to run into a lot more problems then setting themes. – Wyck Jul 19 '12 at 16:11
We share a database in our development environment. See viastudio.com/2011/02/08/… if you're interested in how to set up with out having problems. – joeljoeljoel Jul 19 '12 at 16:31
And how to you preserve database entries....sharing a database is easy, sharing WordPress content/id's/variables stored in the DB is not. – Wyck Jul 19 '12 at 17:09

Why not use a plugin like WordPress › Theme Tester « WordPress Plugins or similar and have the devs use different admin logins? Not sure if Theme Tester handles widget selections, though.

And it's still not a good idea to use one DB for two installs.

share|improve this answer

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.