Title: different css for each page
Last modified: August 19, 2016

---

# different css for each page

 *  Resolved [alexthecatta](https://wordpress.org/support/users/alexthecatta/)
 * (@alexthecatta)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/different-css-for-each-page/)
 * Problem: I need to use a specific CSS style sheet for pages built with a custom
   template I’ve created, and another CSS style sheet for pages built with the standard
   template.
 * I’ve found this (closed) topic
 * [http://wordpress.org/support/topic/attaching-different-css-styles-to-different-page-templates-please-help](http://wordpress.org/support/topic/attaching-different-css-styles-to-different-page-templates-please-help)
 * but don’t know how to make works the following code:
 *     ```
       <?php
       if ( is_page_template('my_new_template.php')) { ?>
       <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/my_new_template.css" />
       <?php } ?>
       ```
   
 * _[Please post code snippets between backticks or use the code button.]_
 * I have to change my_new_template.php and my_new_template.css with my file names.
   What about ‘template_directory’? Sorry if questions may sound stupid, but I’m
   new to PHP.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/different-css-for-each-page/#post-1961479)
 * Does your theme use the [body_class function](http://codex.wordpress.org/Function_Reference/body_class)?
 *  Thread Starter [alexthecatta](https://wordpress.org/support/users/alexthecatta/)
 * (@alexthecatta)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/different-css-for-each-page/#post-1961482)
 * The theme I’m using is Lapofluxury
 * [http://designdisease.com/blog/lapofluxury-theme-released/](http://designdisease.com/blog/lapofluxury-theme-released/)
 * and it seems that the function you mentioned is not used in the theme.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/different-css-for-each-page/#post-1961485)
 * So add it to the theme. Then you’ll be able to switch backgrounds using pure 
   CSS.
 *  Thread Starter [alexthecatta](https://wordpress.org/support/users/alexthecatta/)
 * (@alexthecatta)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/different-css-for-each-page/#post-1961490)
 * Will try and let u know if it works.
 *  Thread Starter [alexthecatta](https://wordpress.org/support/users/alexthecatta/)
 * (@alexthecatta)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/different-css-for-each-page/#post-1961636)
 * Thanks, your suggestion worked out just fine.
 * With body_class function I can now see what class I can use in CSS.
 * Just one more question: how can I apply this class to a specific element (a rigt
   side bar, in this case) that already has a class defined in CSS?
 * Let’s say I have this page-template class, and another class already in place
   to style a <DIV> contained in the body… hope it is clear enough.
 * Thanks for your help.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/different-css-for-each-page/#post-1961637)
 * Use something like `.page-template-about-php #sidebar .right`
 *  Thread Starter [alexthecatta](https://wordpress.org/support/users/alexthecatta/)
 * (@alexthecatta)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/different-css-for-each-page/#post-1961698)
 * thanks, it is working just fine.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘different css for each page’ is closed to new replies.

 * 7 replies
 * 2 participants
 * Last reply from: [alexthecatta](https://wordpress.org/support/users/alexthecatta/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/different-css-for-each-page/#post-1961698)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
