WordPress.org

Support

Support » Themes and Templates » different CSS per page

different CSS per page

  • astima
    Participant

    @astima

    Here is the code for my page.php. I am trying to get it so that if I am on the page with the id of 19 it will use a different CSS class. I want the class to be called craft. What you like doing wrong? and how would I write it in my stylesheet? Would it be .craft h1?


    [code moderated – please follow the forum guidelines for posting code]

Viewing 3 replies - 1 through 3 (of 3 total)
  • the_ID() tag has no parameters.

    Use
    if( get_the_ID() == 19 )

    astima
    Participant

    @astima

    I made that change, but I am not sure if I did it correctly. Probably not, since it’s not working. I pasted my code in paste bin. Here is the link. I’m not very good with a if statement.

    If your theme uses the body_class() function in the body tag you shouldn’t need an if statement or a custom class name to alter existing elements… just use body.page-id-19 before any elements you want to change, like so:

    body.page-id-19 h1 {
       your css here
    }
    
    body.page-id-19 .entry {
       your css here
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘different CSS per page’ is closed to new replies.