different child theme for subdomain

I’ve got a site that I’m trying figure out how to apply different child themes to based on a subdomain. Applying the child themes shouldn’t be difficult, it’s more the .htaccess magic that I’m a bit iffy on.

What I’m after is a site that has say:

example.com/red/
example.com/blue/

Where red and blue are different child themes. But all links can still be accessed as:

example.com/red/blog/
example.com/blue/blog/

Multisite seems like overkill to me, as the sites would have the exact same content, with different style sheets, and different images. I’m thinking that perhaps add_rewrite_rule() would be more appropriate for this situation. But regex is latin to me.

2 Answers
2

I’d encourage you to take one step further back and avoid using URLs to determine theme at all. (And FYI, what you’re describing are subfolders, not subdomains which would be red.example.com.)

The reason not to do this is to avoid duplicate content issues with search engines. Technically, you could work around them, but it can also be confusing to visitors who reasonably expect different URLs to load different content.

Instead, I’d encourage you to look into a “theme switcher” plugin. I’m not familiar with any of them but here are some to get you started:

  • https://wordpress.org/plugins/frontend-theme-switcher/
  • https://wordpress.org/plugins/theme-switcher-reloaded/ (looks abandoned)
  • http://wordpress.org/plugins/theme-switcher/ (looks abandoned)
  • https://wordpress.org/plugins/wp-conditional-themes/ (this would require additional development on top of the theme)

If it were me, I’d carefully look at using localstorage to conditionally load a specific “skin” stylesheet that only includes the color changes it seems like you want.

Leave a Comment