1

I have to show 3 differents template to a person and then say to him: "Please, choose one of these templates and I will use it for your web site"

So the question is: Have I to install 3 differents WP test websites (one for each templates) or can I install only one WP website and install on it 3 templates and give to him a differents links (one for a specific installed template)?

Tnx

Andrea

3
  • Do you mean templates, or themes? Is this like a demo site where you can 'test' against several different themes? Aug 5, 2013 at 8:41
  • @Stephen Harris I mean themes, yes I need a demo site to show 3 different themes Aug 5, 2013 at 9:09
  • 1
    Depends on how dramatic the template changes are. I've installed three themes on one install and then used a theme switcher plugin to switch between them until the client chooses one.
    – Brooke.
    Aug 5, 2013 at 9:25

1 Answer 1

1

I've done for this myself using the plug-in theme switcher: http://wordpress.org/plugins/theme-switcher/ (yes, it hasn't been edited in 2+ years).

These theme stores a cookie in the browser indicating which theme the user has selected (themes are displayed as a drop-down / link list widget - and selecting a theme changes the cookie and redirects you to the home page).

You can dynamically change the theme with the stylesheet filter:

function wpse109022_change_theme_name( $stylesheet ){
    //Change stylesheet to appropriate theme (based on cookiee for example)
    //$stylesheet should be the theme 'name', e.g. 'twentytwelve'
    return $stylesheet;
}
add_filter( 'stylesheet', 'wpse109022_change_theme_name' );

Please note Theme Switcher also uses the template filter, to do the same thing. I believe this is for backwards compatibility. (2.5??)

//add_filter( 'template', 'wpse109022_change_theme_name' );

See source of theme switcher for more details


Caveat: one problem is that WordPress doesn't remember templates between themes. For example:

  • Create page and choose template A from your theme
  • Change theme
  • Select template from the new theme and re-save the page
  • Switch back to original theme. The page no longer has template A

If you're using page templates you'll want WordPress to remember which template to use for which theme. I wrote a plug-in for this: http://wordpress.org/plugins/remember-my-template/

It essentially does the following:

  • Every time a page is saved, store the template as meta data with key _wp_page_template_{theme-name}
  • Filter the page's template via get_post_metadata filter and replace it with the appropriate template based on the theme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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