More... e zine \ WP showcase \ flash
design tech

Style switcher

{ on Jan 15 }

Style switching

Style switching with WordPress themes is very easy with a js file, a second stylesheet and some new images.
It’s not restricted to link colours only, the possibilities are even: a complete different layout can be achieved too.
Of course the basic id’s and classes has to be used: the core php files (e.g. single.php) remains the same,
just apply a new style to the id’s, see the example:

Toggle Stylesheets:
#000 | #fff

Spotted the difference?

What you need:

Download this js file

Upload the style swich file to your themes js folder

Copy your basic theme stylesheet and rename it to style2
Insert the js call in your header:
< script src = " < ? php bloginfo ( ' stylesheet _ directory ' ) ; ? / js / style-switch . js " type = " text / javascript " > < / script >
REMOVE THE SPACES

Insert the two stylesheet calls in your header:
< link rel = " stylesheet " href = " < ? php bloginfo ( ' stylesheet _ url ' ) ; ? > ” type = ” text / css ” title = ” default ” media = ” screen ” / >
< link rel = " alternate stylesheet " type = " text / css " media = " screen " title = " style2 " href = " < ? php bloginfo ( ' stylesheet _ directory ' ) ; ? > / style2 . css ” / >
REMOVE THE SPACES

Note the difference between the title “default” for your basic stylesheet and the second title “style2″.
Vary your basic stylesheet by applying new rules to the id’s and classes.

Upload new images to your themes image folder (if needed)
Insert the script call at an appropriate place:
Styles: < a rel = " no follow " title = " Toggle stylesheets " href = " javascript : chooseStyle ( ' none ' , % 20 60 ) " > # 000 < / a> | < a rel = " no follow " title = " Toggle stylesheets " href = " javascript : chooseStyle ( ' style2 ' , % 20 60 ) " > # fff < / a >

Voila, there you go.

Further reading and explanation:

Another HowTo at A list Apart

Extensive HowTo at Dynamic Drive




Published in Design, Themes | Tags: | Browse the Archives

miloIIIIVII is a graphic and Web designer based in Munich, who works with clients to create exciting and cutting edge web design
That's all. Want more info? Inspiration?
View the lifestream or the Gallery, subscribe to the full RSS feed or get it via Email.

Share



2 excellent Responses

  1. 1 CO2 Says:

     

    on May14 08

    Thanks for this tutorial. I think it would be useful to also have a link to a plain text file (or even a text area box containing the code) because copying the spaced out code from the screen then removing the spaces actually took far longer than expected.

    Just a thought…

  2. 2 miloIIIIVII Says:

     

    on May14 08

    Good idea, will post the txt file as a download.