WordPress Easy Theme Style Switcher


/ Published in: PHP
Save to your folder(s)

Easiest way to switch theme styles for WordPress demos.


Copy this code and paste it in your HTML
  1. //place in php tags above DOCTYPE declaration
  2. <?php
  3.  
  4. //Set Default style
  5. $demo_style = "style";
  6.  
  7. //Retrieve Cookie (if exists)
  8. if( isset($_COOKIE['your-theme-style']) ){
  9.  
  10. //Set Style
  11. $demo_style = $_COOKIE['your-theme-style'];
  12.  
  13. }
  14.  
  15. //Retrieve Style form URL
  16. if( isset($_GET['style'])){
  17.  
  18. //Set Style
  19. $demo_style = $_GET['style'];
  20.  
  21. //Set cookie
  22. setcookie('your-theme-style', $demo_style);
  23.  
  24. } ?>
  25.  
  26.  
  27. // Put stylesheet link in head
  28. <link href="<?php bloginfo('stylesheet_directory'); ?>/<?php echo $demo_style; ?>.css" rel="stylesheet" type="text/css" media="screen" />
  29.  
  30.  
  31. //links in theme page
  32. http://www.yoursite.com/yourtheme/?style=style
  33. http://www.yoursite.com/yourtheme/?style=another_style
  34. http://www.yoursite.com/yourtheme/?style=yet_another_style

URL: http://www.mojo-themes.com/demo/stereotype-one-page-wordpress-theme/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.