Blog Overhaul

The release of WordPress 3.0 introduced a lot of good stuff behind the scenes that I wanted to take advantage of. The new built in Twenty Ten theme incorporates all this new stuff and is pretty nice so I ditched my old custom theme that I was never super happy with. Overall changes:

  • Switched to Twenty Ten theme
  • Customized header with one of my panoramas from Kauai (Menehune Fishpond just south of Lihue)
  • Built navigation menu using new Menu feature
  • Added Contact form
  • Added Google Reader snippet to display recent starred items in sidebar
  • Setup footer widgets with Recent Posts, Tag Cloud, Pages and Categories for unobtrusive navigation links
  • Deactivated Wordbooker, less content Facebook has of mine the better
  • Enabled threaded comments, giving it another try

Show AdSense to Google Search visitors in WordPress

I put AdSense ads on my WordPress plugin pages since the donation button wasn’t 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’t 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', 'search.', 'del.icio.us/search', 'soso.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('scratch99_fromasearchengine')) {
if (scratch99_fromasearchengine()) { ?>
INSERT YOUR ADSENSE CODE HERE
<?php } } ?>

And that’s it. Visitors coming in from Google and some other search engines will have whatever ad you want displayed. There are plugins that will do this all for you, but this is simple enough to build straight into your theme. The only downside is if you are using caching, but odds are only your older posts are going to be getting hits from Google. If a page happened to get cached with the AdSense code inserted then everyone will see the ads. Not really a big deal to me, but just something to be aware of.

Blog CSS makeover

Did a little work on my blog’s theme to bring it up to speed with WordPress 2.7. Been using the same theme with a few modifications since WP 1.5 so it was time for a little refresh. List of changes:

  • New font and font sizes.
  • Reset all padding and margins. This made it easy to get consistent spacing across the entire site using margins only.
  • New comments output with gravatar support. Using the new wp_list_comments function with a custom callback to separate trackbacks.
  • Moved header text down so the tails of the Y’s go into the background of the main column, that’s the extent of my creativity.
  • Category and tag pages only show excerpts now.
  • Edited robots.txt and sitemap.xml to avoid Google indexing duplicate content on archive pages.
  • Increased total container width to 895px, my stats show only about 1.2% of people who visit my blog are on 800 x 600 so there’s no point in designing for them anymore.
  • Added code to show Google AdSense to visitors coming straight from a Google search. Did that about a month ago, I’ve made $7 inĀ  February so far.

Blog facelift

Things were getting a little old around the blog so I spruced things up a bit. Ditched the nav bar across the top, it was a bit of a pain to work with. Put login stuff in the sidebar like Nathan has on the Blarg, RSS buttons down at the bottom (which you should use, if you don’t know how or why please ask) and a thing for my flickr account. There should be more changes and more posts coming.