WordPress.org

Ready to get started?Download WordPress

Forums

Best way to add different stylesheets for different pages (4 posts)

  1. kjeft
    Member
    Posted 4 years ago #

    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?

  2. zartgesotten
    Member
    Posted 4 years ago #

    I like to use the Plugin called ClassyBody by Alister Cameron. Works great and I use it on many pages.

  3. kjeft
    Member
    Posted 4 years ago #

    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...

  4. blogologist
    Member
    Posted 4 years ago #

    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.

    Cheers,

    -Alister

Topic Closed

This topic has been closed to new replies.

About this Topic