So I’ve been working on restructing the 449 site a little this morning, we originally put it together in about a day, so I’ve been working on giving it a better “flow” and generally tidying up the code. The only thing that’s been causing me an irritation is that, for some obscure reason, the wordpress conditional tag is_home()
doesn’t appear to return TRUE
on the homepage :S So in the sidebar where I want to serve up the “Great content needs a great design” call-to-action when you’re on the homepage, but no other pages, I’ve had to invent a little hack:
<?php if(empty($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] == '/'){ echo 'code here'; } ?>
What this is doing is checking the “REQUEST_URI”, the appended part of the URL (eg/ “/about/” or “/contact/”), and making sure it’s not empty or “/” (which would point to the homepage). It’s a filthy dirty hack, but for now it gets the job done
You’ll probably find that you’re calling a specific page via a wordpress query on your home page right?
like query_posts(’page_id=2′); … rite?
your problem has happened to me a few times too and i realized that for me, this was the cause. so instead of is_home(), i used is_page(’2′) and that seemed to return TRUE.
give it a whirl
Comment by MarkB — 05/02/08 @ 5:31 am
hey Mark, thanks for replying. This was actually one of the first things I thought of, but even when I reset wp_query it still didn’t work.
Thanks!
Comment by Chris Garrett — 05/02/08 @ 10:38 am