I want to display different header sections on the home screen and article screen. I thought something like this would work:
<? php if( is_home() ) { ?>
<header class="header home" role="banner">
<?php } else { ?>
<header class="header" role="banner">
<?php
}
?>
Where, in my CSS, the following takes place:
.header {
background: $blue;
&.home {
background: $blue;
}
}
In reality I should see a green header on the home page, and a blue one on the homepage. But I don’t. Any clues?
At the last, we have discovered that the problem is a single space between <? and ‘php’.
Thanks and Enjoy your code!
try after change this
to
Assuming the code you posted is the code you’re using code, you apply the
$blue
attribute to both.header
and.header.home
instead of applying something like$green
to one of them.If you’ve declared a variable $green to hold a hexadecimal value representing a green color try
See this JSFiddle for a working example: http://jsfiddle.net/SSCnJ/
It might not be the solution, but you could also try changing this
to this
assuming that $blue holds either a hexadecimal value with a # in front, or is an rgba value.
Hope this helps.
try using
is_home() will return true on home page only if you have set Front page displays -> Your latest posts in Reading settings.
For more info read http://codex.wordpress.org/Function_Reference/is_home#Blog_Posts_Index_vs._Site_Front_Page