Google AdSense in WordPress sidebar but not for Pages

(Update: I took out the ads).

After resisting and incredible amount of pressure, I gave up and put Google's AdSense ads in my blog. My little corner of the cyberspace was one of the only places with more than two readers (I have three o four) without the pervasive publicity links.

So what the heck, I decided to dive in shouting "show me da money!" and claim my 20 or 30 cents that I was missing out. I hope that if everything pans out my silly thinking aloud will pay for my addiction to Tim Hortons . (I need my daily doses of medium double-double coffee and donut, and that's like CND $2.09 !).

I don't like to have my site full of advertisement; we already have John Chow with his good ad tips for that, so I placed an ad block at the bottom and another in the sidebar. The problem was that the sidebar add block was showing also in my "about me" pages and I don't like to have ads there, especially when one of the ads that appeared in this blog was Living with a Sociopath?; most of the ads are related to the text in the articles but sometimes you get an oddball.

I decided to make the modifications in WordPress and the current theme so that I don't display ads in the sidebar for my "pages", but just in the regular posts.

These are my notes:

Copy the sidebar.php of your theme into another file without the AdSense code, 'sidebarpage.php' for example.

Edit the page.php file for your theme, for instance ./wp-content/themes/mistylook-101/page.php , and rename the function get_sidebar() at the bottom, for instance get_sidebarpage()

Edit the ./wp-includes/general-template.php file and copy the get_sidebar() function but now this function will call the sidebarpage.php:

function get_sidebarpage() {
if ( file_exists( TEMPLATEPATH . '/sidebarpage.php') )
load_template( TEMPLATEPATH . '/sidebarpage.php');
else
load_template( ABSPATH . 'wp-content/themes/default/sidebar.php');
}

And that's all.