Posted By

vagrantradio on 12/16/10


Tagged

wordpress


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

baires
qubestream
hndrkii


WordPress Easy Theme Style Switcher


 / Published in: PHP
 

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

Easiest way to switch theme styles for WordPress demos.

  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

Report this snippet  

You need to login to post a comment.