1

i want to switch the theme of my WP website automatically by random for my users in order to do different A/B testing actions. switch_theme is not working cause that changes the theme in the database.

But i want to do this for each user by random without changing the general themesetting in WP. Like the function WP provides when previewing a theme. How can i do that? I do not need help with the randomize function etc. I just need a hint how to switch the theme for a usersession.

A plugin is not a solution, cause there is none i could use to fulfill my requirements for the A/B test. I need to program individually for my needs.

Thanks in advance for your help! René

3
  • You could consider reviewing/forking Rarst's Toolbar Theme Switcher plugin for ideas or a starting point. It will allow admin users (this can be changed with a filter) to switch themes without globally making the change for all users. – Dave Romsey Jan 29 '17 at 19:40
  • I don't understand what is it that you are asking for. how to detect a session (use cookie), or how to select progrematically which theme is being used? – Mark Kaplun Jan 29 '17 at 20:14
  • I would use the php session of each user to switch theme only once for a user. Then select randomly one of my 3 themes. These 3 themes will have complete different layout and adsense placements. With this a/b test i want to test the performance of each theme. – rezwiebel Jan 29 '17 at 21:10
0

The way we did it was by setting up separate WordPress setups on subdomains:

  • theme1.ourcompany.org
  • theme2.ourcompany.org
  • theme3.ourcompany.org

We used a server script cooked up by the IT Administrator to route users at random to either one of the subdomains. The difference in domain names made for a clear distinction between datasets when we compiled the analytics.

2
  • Ok, that would be a solution. But shouldn't it be possible without separate installations? I found this: function custom_load_twenty_ten_template() { return 'twentyten'; } function custom_load_twenty_ten_stylesheet() { return 'twentyten'; } add_filter( 'template', 'custom_load_twenty_ten_template' ); add_filter( 'stylesheet', 'custom_load_twenty_ten_stylesheet' ); but it did nothing on my site. – rezwiebel Jan 30 '17 at 9:30
  • I found out, why it did not work. Cause this script has to be loaded via a plugin. When placing into functions.php, it is too late, cause a lot settings for rendering the WP website is already loaded. Now it works. – rezwiebel Jan 30 '17 at 12:28

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.