Advertising Blogs in Exchanges

If you want to advertise your blog in a traffic exchange, but don’t want to risk your adsense account, I’ve got the solution for you! Basically what this code will do is prevent the adsense from showing when the blog is viewed inside an exchange.
The examples below are currently used in this blog. It is powered by Wordpress 2.0 and uses permalinks.
Place this PHP code BEFORE the adsense code
if ($_SERVER["QUERY_STRING"] != "exchange") {
?>
Place this PHP code AFTER the adsense code
}
/* END: if ($_SERVER["QUERY_STRING"] != "exchange") { */
?>
Adding your site to the exchanges
All you have to do now is enter the URL to your blog with ?exchange at the end of the URL. For example:
http://www.timlinden.com/blog/?exchange
This will make the above code NOT display the adsense. Once you’ve got those codes before and after each adsense code you’ll be all set. Note that this’ll only work in the templates where PHP is executed!
Bonus: Making all the links open in a new window!
You can also add the following code inside the HEAD /HEAD tags of the header. It will make all the links on the page open in a new window ONLY when shown in the exchanges:
if ($_SERVER["QUERY_STRING"] == "exchange") {
echo "
}
?>







January 4th, 2007 at 11:53 pm
This is awesome, Tim! You sure make me wish I had gone into programming - I’d love to be able to come up with things like this.
Thank you!
January 5th, 2007 at 10:46 am
RE: Note that this’ll only work in the templates where PHP is executed!
What I mean by this, is you can’t use the code inside your posts. Otherwise the post editor will treat it as HTML and not actual PHP code. All the actual templates are PHP so you can use them in any of them (except the style sheet)