WordPress.org

Ready to get started?Download WordPress

Forums

Category specific css (6 posts)

  1. mymonkeymind
    Member
    Posted 5 years ago #

    Hello,

    I want to have a specific style sheet loaded for single posts that are in a specific category. So if the category is "dog" then "dog.css" would be loaded in addition to the style.css file that loads upon every page.

    Would someone help me out with this?

    Thanks in advance,
    Marcus.

  2. crayoncrisis
    Member
    Posted 5 years ago #

    You just need a Category Template and also check out
    Different Category Format.

  3. mymonkeymind
    Member
    Posted 5 years ago #

    Thanks for the response, crayoncrisis. And unless I am misreading the information in the links you provided, I could make a specific template for a category, but that would be used for the category page.

    What I want to do is assign a style sheet for a single post (that applies to all posts) in a category.

    Alternatively, Ideally I would like the ability to do it to a for a single post with a specific tag. It makes no nevermind whether I use tags or categories, I just want to assign a stylesheet to a single item page that is either tagged or categorized to a corresponding item. Did that make sense?

    Did I misread something?

  4. crayoncrisis
    Member
    Posted 5 years ago #

    Ah, I think that you are absolutely right. I didn't get that part. The Template Hierarchy for single post display seems to be:

    1. single.php
    2. index.php

    I've been using the Sandbox theme lately, and it has a function giving classes to the body element. Not quite what you were asking about, but it does give you a body with a class like s-category-dog, letting you style that specifically.

    Hope someone else can answer about the seperate style sheets though, I want know that too now that I see this wouldn't do the trick for a single post.

  5. mymonkeymind
    Member
    Posted 5 years ago #

    I'm also using the Sandbox theme, and the class selectors for individual elements are great. But what I'm looking to do is to style a whole bunch of selectors based upon a particular category or tag.

    Is there a way to put a statement in the single.php page that goes something like:

    if category = dog
    then load dog.css
    else load owner.css?

  6. Anointed
    Member
    Posted 5 years ago #

    this is exactly what I came here looking for!

    Hope there is a solution someday.
    Seems that it shouldn't be that hard, just not sure what the best way to attack this problem is.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags