Setting up Google AdSense on a Wordpress Blog

These instructions show how to set up a number of Google Adsense ads with the default theme on a wordpress blog. These instructions were written to describe how AdSense ads were added to http://lorcancoyle.org/blog.

Signing up for Google AdSense

First you must sign up for Google AdSense.

Inserting a Skyscraper Ad at the Bottom of the Right Sidebar

Examples of Banner ads are shown here. These instructions will place the Google Ads at the bottom of the right sidebar.

Go to the location of your blog installation (mine is /var/www/lorcancoyle.org/blog).

cd /var/www/lorcancoyle.org/blog

Open the sidebar php document for the default theme.

nano wp-content/themes/default/sidebar.php

Now copy the sample code given to you by Google and add it to the end of sidebar.php (just before the final </ul>). This end of the document should now look like this (i have replaced sensitive information with <TEXT IN CAPITALS>):

...
<?php /* start of adsense code */?>
<li>
  <script type="text/javascript"><!--
    google_ad_client = "pub-<CLIENT NUMBER>";
    google_ad_width = 120;
    google_ad_height = 600;
    google_ad_format = "120x600_as";
    google_ad_type = "text_image";
    //<SOME DATE>: <URL LOCATION>
    google_ad_channel = "<CHANNEL NUMBER>";
  //--></script>
</li>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<?php /*end of adsense code*/ ?>
</ul>
</div>

Inserting a Banner Ad After Each Post

Examples of Banner ads are shown here. These instructions will place the Google Ads after the meta-data note on the entry and before the comments.

Go to the location of your blog installation (mine is /var/www/lorcancoyle.org/blog).

cd /var/www/lorcancoyle.org/blog

Open the single php document for the default theme.

nano wp-content/themes/default/single.php

Now copy the sample code given to you by Google and add it to the end of simple.php This end of the document should now look like this (i have replaced sensitive information with <TEXT IN CAPITALS>):

...
  <?php /* start of adsense code */?>
  <script type="text/javascript"><!--
    google_ad_client = "pub-<CLIENT NUMBER>";
    google_ad_width = 468;
    google_ad_height = 60;
    google_ad_format = "468x60_as";
    google_ad_type = "text_image";  
    //<SOME DATE>: <URL LOCATION>
    google_ad_channel = "<CHANNEL NUMBER>";
  //--></script>
  <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
  <?php /* end of adsense code */?>
 
  <?php comments_template(); ?>
 
  <?php endwhile; else: ?>
 
  <p>Sorry, no posts matched your criteria.</p>
 
  <?php endif; ?>
 
  </div>
 
  <?php get_footer(); ?>

~~DISCUSSION~~

public/adsense_wordpress.txt · Last modified: 2008/08/09 09:59 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki