Protecting your AdSense for Search Earnings
- Posted On: April 2nd, 2007
- Filed Under: Web Design
- Tagged As:
Here's a quick tip that doubles as a follow up to my recent post on incorporating AdSense for Search into your WordPress Theme. In case you missed it, Google discourages site owners from using Google AdSense for Search when searching their own pages.
While it's true that you can use the search dialogue that's built into WordPress' administrative interface, sometimes you just want to jump in and get to work. This is where a familiar piece of WordPress code (a bit that I introduced when talking about AdSense and the Postpreview pane) comes in handy.
In that post I went over how to prevent WordPress from displaying AdSense ads whenever you're reading your own site. This cuts down on false impressions and decreases the chances of you wasting any high paying CPM or CPC ads. With a slight tweak to that code you can actually get WordPress to use two search dialogues. One for you and one for your reader.
Let's start by looking at the code which we used in the original post - we're just going to switch the AdSense code with the AdSense for Search code.
<?php global $posts, $current_user; if($posts[0]->post_author != $current_user->ID) { ?>
AdSense for Search Code goes Here
<?php } ?>
The above code will check to see if the current user is a post author. If they are not then it will display the AdSense for Search search dialogue. To display the non-AdSense box simply include an else statement - we do that by editing that last line.
<?php } else { >
Regular Search code goes here
<?php } >
Presuming you know what your regular search box would be it's that simple.
If you're using a theme provided by another author simply check out their original code and see what you need to do. If you have any questions or need some help setting up your personal search dialogue drop me a line and I'll gladly give it a look.


