Support » Themes and Templates » Best way to add different stylesheets for different pages

  • Hi everybody

    I am using different CSS files on all my pages (they all have their own colour codes and just look different to each other) and am wondering which approach is the best to go.

    At the moment I am using a massive elseif function to echo out which stylesheet to link to. Which actually works fine but it feels a bit silly to have in the header. Is this really the proper way of achieving this or is there a better way?

    I was thinking that perhaps it would be better to create separate headers for the pages instead but that also feel a bit redundant as they are all coded the same.

    What do you think is the best way to do this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I like to use the Plugin called ClassyBody by Alister Cameron. Works great and I use it on many pages.

    Thanks for your quick reply.

    I have been thinking about this too. Well, adding it manually was my initial thought, but that would mean I end up with a single huge CSS file. Doesn’t really feel like the right way to go either…

    To wearitall and others.

    I’m thrilled people still use my ClassyBody plugin, but the functionality (and then some) is now part of WordPress core.

    So unless you’re not keeping up with the latest updates, you should really use the “native” approach.

    Of course, the body class tags/identifiers are a little different if you’re migrating from ClassyBody, if you’re already using it.



Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Best way to add different stylesheets for different pages’ is closed to new replies.