WordPress.org

Ready to get started?Download WordPress

Forums

different CSS per page (4 posts)

  1. astima
    Member
    Posted 2 years ago #

    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]

  2. Andrei Olsen
    Member
    Posted 2 years ago #

    the_ID() tag has no parameters.

    Use
    if( get_the_ID() == 19 )

  3. astima
    Member
    Posted 2 years ago #

    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.

  4. Caroline Moore
    Member
    Posted 2 years ago #

    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
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags