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.

Is there a way to have a site use a theme that is specified by the URL?

for example the same site content, database and WordPress install where:

  • domain_x.com uses theme_a with company_branding

  • domain_y.com uses theme_b with alt_company_branding

share|improve this question
add comment

2 Answers

EDIT

On second thought: no, both Themes couldn't use the same database. If they did, they would have to have exactly the same settings, including active Theme, activated Plugins, and settings - which includes home_url().

There may be other ways to go about it, but this isn't one.

ORIGINAL ANSWER

If I'm following your question properly, then sure. Just have two separate WordPress installations that use the same database.

(Note: there could be unintended consequences of writing to the same DB from two different WP installs.)

share|improve this answer
    
thanks chip - to be clear, it is a single site, ie one istall, it just needs to look different on each URL - i did find a plugin called domain-theme but it got discontinued after v3.x - if you do think of anything do LMK –  steve Sep 1 '11 at 20:31
add comment

I don't see why you couldn't do that. There are a few steps you'd need to go through, though.

  1. In wp-config.php, check for the domain name being accessed (probably through the $_SERVER variable). Here you're going to define a few constants to override the 'home' and 'siteurl' options (see the WP_HOME and WP_SITEURL examples in the Codex here)

  2. With a plugin (since plugins load before themes), add a filter to stylesheet to return the path to the stylesheet you want to load, and optionally add a filter to template to return the name of the theme you want to use. Here you're probably also checking the $_SERVER superglobal, or maybe you've defined a constant earlier in wp-config that you're checking here.

As Chip pointed out, there are a lot of moving parts in themes (options, active widgets, etc), so I couldn't see this working smoothly if the themes in question were too very different (ie. differently named sidebars, different menu locations, or worse, different registered post types). But it could work very well if the main difference is just a stylesheet file, or maybe a few template files. Maybe you could make the themes you're going to be switching between as child themes of a common parent, and only change the style.css files and whatever assets absolutely have to be different between them.

share|improve this answer
add comment

Your Answer

 
discard

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.