This is our Blog. We thought we should have one, for rambling and sharing stuff…

  1. Chris Garrett's Gravatar

    A wee wordpress hack…

    04/02/08 by Chris Garrett2 Comments

    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 :)

    Tags: , ,