I used this snippet of code to set a different css class or id based on the page template.
1 2 3 4 5 6 7 | <div id=" <?php if (is_page_template( 'template-home.php' )){ echo "content-home" ;} /*elseif (is_page_template('template-diff-bg-demo2.php')){ echo "template-diff-bg-demo2";}*/ else { echo "content" ;} ?> "> |
It could be modified to be conditional based on being the the home page as well.
Also note that is had to be put in the code/document as a single line for it to work…..don’t know why…….
1 | <div id= "<?php if (is_page_template('template-home.php')){ echo " content-home ";} /*elseif (is_page_template('template-diff-bg-demo2.php')){ echo " template-diff-bg-demo2 ";}*/ else{ echo " content ";} ?>" > |
This snippet is based on code taken from this article on the Fearless Flyer website:
http://fearlessflyer.com/2009/05/how-to-change-the-background-dynamically-in-your-wordpress-theme/
Revisions: (Show)
No comments yet.