How to Insert Google Adsense ads into a WordPress blog by Modifying Theme Files

20 February, 2010 (12:17) | Google Adsense Earning, WordPress Blogging | By: max

In a previous post we have seen how easy it is to add Google Adsense ads to a WordPress blog sidebar by a Text Widget.      

But what if you wish to place the Google Adsense ads not in a sidebar but in any other screen location of your blog?     

A way to achieve that is by manually modifying the source template files of the WordPress theme you are using.     

The theme source files are reachable through the Appearance/Editor entry in the admin area.     

The number and names of template source files can vary from theme to theme.     

However, there is a bunch of them which are commonly present and keep their roles across themes.     

Amongst them, there are the following ones:     

  • Main Index Template (index.php)
  • Header (header.php)
  • Footer (footer.php)
  • Sidebar (sidebar.php)
  • Single Post (single.php)

So, for instance, should you wish to have Google Adsense ads displayed on every single post, then you need to place the related Google script into the single.php source file.     

As an example, just have a look at the following image:     

Wordpress Single Post Theme File Google Adsense Ad Script example

Wordpress Single Post Theme File Google Adsense Ad Script example

and at how the Google Adsense ads get accordingly displayed at the beginning of a single post on the web:       

Wordpress Single Post Google Adsense Ad example

Wordpress Single Post Google Adsense Ad example

Do remember that whenever you automatically update the theme you are using to a new version then you have to re-insert the Google ad scripts in the template source files.

  • Share/Bookmark