Different themes according to cookie (3 posts)

  1. kjeldsen
    Posted 6 years ago #

    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,

  2. muthukswamy
    Posted 6 years ago #

    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:
      Example: http://www.example.com/?preview_theme=Test Theme

    I hope this helps.

  3. muthukswamy
    Posted 6 years ago #

    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));

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.