WordPress.org

Ready to get started?Download WordPress

Forums

php body_class property mix up (6 posts)

  1. whitehats
    Member
    Posted 4 years ago #

    Hi,
    I am trying to use <body <?php body_class();?>> to apply different CSS rules to every template. The problem is, the properties I have specified in the CSS get mixed up. i.e. The H1 font color for body.home get applied to body.category-blog H1, although I have specified both of them separately in the CSS.

    Is there a parent-child relationship between the body classes? I have not explicitly specified it so in the CSS, but does WordPress create any such relationships?

    Thanks,
    -Tejas

  2. ajithkpunnoose
    Member
    Posted 4 years ago #

    Its better to use Firebug to find out. It shown parent child inheritance and the CSS applied to each element hierarchically.

  3. esmi
    Forum Moderator
    Posted 4 years ago #

    Is there a parent-child relationship between the body classes?

    No. However, any given page on your site will have multiple body classes applied to it.

  4. whitehats
    Member
    Posted 4 years ago #

    Ajit, yes I use Firebug. That how I actually found that the class were not exclusively used for their own pages.
    Esmi - is there a work-around to this?

  5. esmi
    Forum Moderator
    Posted 4 years ago #

    How specific do you need this CSS to be? It could be just down to the order in the stylesheet - although I'm having trouble figuring out how the classes "home" and "category-blog" can appear on the one page.

    Any chance of a url?

  6. whitehats
    Member
    Posted 4 years ago #

    It's on localhost currently, but I will try to push it on the server and see what we can do. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags