I have a wordpress site. I have a div that I only want to appear on the homepage (in the header). What type of php if statement do i need…
In other words:
only show …. in the header of the main blog index page. Problem is the header itself is loaded in every page.
Thanks!
See: http://codex.wordpress.org/Function_Reference/is_home
Using above code works fine as long as you are not setting static Page for the Front Page display from here Administration > Settings > Reading.
But this code will work irrespective of whether the main blog page is showing or you have set a static page to show on home page.
You could also solve the problem with CSS.
Set the div to
in your css.
Then find the body class page-id for the front page and set the css for that as:
This will hide it on every page except the page you want to show it on.
There’s always
$_SERVER['REQUEST_URI']
you can use to determine which page you’re at. For homepage it is usually just ‘/’. so: