Forums

Change CSS only on custom template page (2 posts)

  1. rockstar_tom
    Member
    Posted 2 years ago #

    Hello,

    I've created a new custom template 'work_home.php' based on the 'page.php' template. I want to change the css ONLY in 'work_home.php'.

    I know you can target a specific template in my css like this:
    .home #container {border:red;}

    Any help is much appreciated :)

  2. esmi
    Theme Diva & Mod
    Posted 2 years ago #

    If your theme uses the body_class():

    <body <?php body_class(); ?>>

    in header.php, you should find that any page that uses the work_home.php template should have a page-template-work_home-php class attached to the body element. You then use something like:

    .page-template-work_home-php #container {
    }

    to apply CSS to pages that use this template.

Topic Closed

This topic has been closed to new replies.

About this Topic