I'd like to be able to set a wordpress theme for certain subdomains, but still load the same content for all installations.

For example, I have www.domain.com that loads the default template with default content. I'd also like to have mobile.domain.com, that too loads the same content but a separate template.

What would be the best way to go about this?

  • Usually in this type of scenario the template is the same, but a different style sheet is loaded when a mobile browser is detected. If you want a plugin to take care of that, there are some good ones out there like WP Touch (commercial) or plenty of free ones too. – mike23 Jun 30 '11 at 16:50
  • We have a custom template made up, and I want the functionality to choose any kind of template based on the subdomain, not just limiting to mobile site design. Any idea? – Don Wilson Jul 11 '11 at 22:44

Without more detail about the kind of template you'd be serving up, the best I can advise is that you can use the 'template_redirect' hook to override the entire Template Hierarchy.

A more delicate way to do this would be by using on of the more specific filters. Each of the conditional get_*_template() functions in template-loader.php has a filter of its own which you can use to return your own template name. Look in includes/themes.php to see those filters.

Most of them end up using get_query_template(), which dynamically creates the filter name in a consistant way, but some of the others like author and category are separate - look around to find which if any suits you best under different circumstances.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.