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
usestheme_a
withcompany_branding
-
domain_y.com
usestheme_b
withalt_company_branding
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.)
I don’t see why you couldn’t do that. There are a few steps you’d need to go through, though.
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)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 totemplate
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.