• Home
  • New Entries
  • Popular Entries
  • Submit a Story
  • About

Show AdSense to Google Search visitors in Wordpress ...

I put AdSense ads on my Wordpress plugin pages since the donation button wasn exactly raking in the dough. I inserted my AdSense code straight into these pages content. Looking through some of my stats I noticed a few of my posts got lots of hits from Google Search that would be good for ads. I didn want to show ads to my friends and normal readers so I went looking for a simple solution.

I borrowed some of the code used in this post, http://www.scratch99.com/2008/01/shylock-adsense-plugin-hack-to-avoid-adsense-smart-pricing/. One template function checks the referrer, if it returns true then you display your AdSense code in your post template, single.php in my case. This goes in your functions.php:

function scratch99_fromasearchengine(){
$ref = $_SERVER[HTTP_REFERER];
$SE = array(/search?, images.google., web.info.com, isearch., wouldel.icio.us/search, isoso.com, /search/, .yahoo.);
foreach ($SE as $source) {
if (strpos($ref,$source)!==false) return true;
}
return false;
}

and this goes in your post template where you want the ads to be displayed:

<?php if (function_exists( iscratch99_fromasearchengine)) {
if (scratch99_fromasearchengine()) { ?>
INSERT YOUR ADSENSE CODE HERE
<?php } } ?>

 Original Source:
http://geekyweekly.com/2009/show-adsense-to-google-search-visitors-in-wordpress

AddThis Social Bookmark Button

Posted at 11:50:05 am | Permalink | Posted in Search Engines  

Related Stuff

Google Buzz Button Wordpress Plugin Released

If you are looking for a Google Buzz button to add into your Wordpress site then we have released the first Wordpress plugin exclusively ...

Plug And Play Ecommerce With Wordpress Plugins

Since 2003 Wordpress has slowly been gaining popularity amongst the elite of the internet, the bloggers. It is one of those few things ...

Add Google Search to Your WordPress Blog

The native WordPress search does not return very relevant results, thus it makes a lot of sense to add Google Search into your WordPress ...

Add More Sidebars to Your WordPress Theme

You can add more than one sidebar section to your WordPress site. For example, with the stc-intermountain.org site, I added a whole bunch ...

Series Posting in Wordpress

In my functions.php file, I have some code which implements series posting. This relies on the thematic ...

Top Stuff

Free Blogger templates Anime Themes

Wordpress Guestbook Generator Plugin

48 Unique Ways To Use WordPress

GeekLog

WordPress Single Post Templates

Get The Image WordPress Plugin



About Webloglines

Webloglines is a project offers a comprehensive collection of blogging services, articles, themes and plugins from around the world. Whether you're looking to promote your own blog or find blogs on various topics, this site is for you.


Search


Topics

  • Adsense (12)
  • Blogging Tips (73)
  • Blogs Slides (25)
  • Blogs Websites (22)
  • Digg (20)
  • How to Blog (129)
  • Search Engines (9)
  • SEO (135)
  • WordPress Plugins (269)
  • WordPress Security (75)
  • Wordpress Themes (99)
  • Wordpress Tips (162)

© 2006 www.webloglines.com. All Rights Reserved. Powered by IRange