WordPress.org

Support

Support » Themes and Templates » Different themes according to cookie

Different themes according to cookie

  • Is it in any way possible the change the theme used in WordPress, according to a value set in a cookie?

    I would like to test whether a new layout works for the users and I am thinking of deploying a “Betatest this site” strategy, by allowing the user to set their own preference (new vs. old).

    Kind regards,
    Kjeldsen

Viewing 2 replies - 1 through 2 (of 2 total)
    1. Install this plugin: http://wordpress.blogos.dk/showcaseext/
    2. Edit the plugin file “theme-showcase-ext.php

      Line 151, 180: $theme = $_GET[$preview_theme_query_arg];

      Replace both lines of code with:

      $theme = $_COOKIE['current_theme']!='' ? $_COOKIE['current_theme'] : $_GET[$preview_theme_query_arg];
      setcookie('current_theme',$_GET[$preview_theme_query_arg],time() + (86400 * 20));

      Note: “20” in the above code is 20 days, change it based on your requirements.

    3. Now link to your Beta-test theme by using the following URL:
      <BlogURL>/?preview_theme=<ThemeName>
      Example: http://www.example.com/?preview_theme=Test Theme

    I hope this helps.

    Use this code instead to remove the error seen in admin pages:

    $theme = $_COOKIE['current_theme']!='' ? $_COOKIE['current_theme'] : $_GET[$preview_theme_query_arg];
    if($_GET[$preview_theme_query_arg]!='') setcookie('current_theme',$_GET[$preview_theme_query_arg],time() + (86400 * 20));

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different themes according to cookie’ is closed to new replies.
Skip to toolbar