Monday , 21 April 2014
Home / Blog Tips / Blog Money / Add Google Adsense To WP Blog Content

Add Google Adsense To WP Blog Content

Adding Google Adsense To WP Blog Content can prove to be a little tricky for those of you that are fairly new to WordPress blogs, therefore this is going to be the definitive guide that will not only show you where to place Adsense, but also & more importantly how.

To start with, lets understand one thing, wherever you can place Adsense, you can place any other advertisements using the exact same methods that I’m going to show you. In fact the only reason that this guide mentions Adsense in the title, is because that terminology is what gets searched for far more than just “Placing Adverts In Your Content”

The 3 main areas that we can use for Adsense;

1. The Header Area (Usually a 468 x 60 Banner)
2. The Sidebar (Usually as a widget of various sizes, 300 x 250 & 120 x 600 being the commonest)
3. The Article Content (Usually an Adsense Block 300 x 250 & 250 x 250)

Before proceeding further, I should point out that I hate having to deal with large chunks of Java script code when placing my adverts, therefore I have installed a neat little plugin called ” Datafeedr Random Ads V2 “. This plugin allows me to insert a single line of php code wherever I choose to place my adverts & has the added bonus of being able mix & rotate adverts from many different sources.


Adsense In The Header


The header area is most often dealt with by the theme, but just in case it is not, we need to create a div in the header in order to place the Adsense code & to be able to style it.

Now open the header.php file of your theme, in the WordPress editor, place the lines of blue code that follow, just after the end logo comment & before the closing div of your header.

<!–end: logo–>

<div class=”468x60banner”>
<?php if (function_exists(‘dfrads’)) { echo dfrads(’4483472′); } ?>

<!–end: header–>

You will notice above, the line of php code used to insert the advert from the Datafeedr Random Ads V2 plugin. Ok once you have inserted the lines of code, save and close header.php . Now open your style.css in the WordPress editor, scroll through until you find reference to header & logo, after the entry for logo paste in the following block of code;

.468x60banner {
float: right;
background: #FFF;
margin: 15px 10px 0px 0px;
width: 468px;
height: 6opx;
padding: 0px;
border: 3px outset #cccccc;

The above code will allow you to style the banner, adjust the margin & padding to fit your header, although to be honest you would probably find it looks just fine with this code.

Adsense In The Sidebar


Placing Adsense in your sidebar is much easier, especially if you have installed the plugin I mentioned earlier. Simply sign into your WordPress admin panel & select widgets from your left hand menu. If you have installed the Datafeedr Random Ads V2 plugin then it will be included in the list of widgets and can be dragged over and added to any part of your sidebar, adjustments can be made via the widget itself as shown below.

Add Google Adsense To WP Blog Content

If however you have not installed the plugin, then all that is required is to use a html/text widget instead.

Simply drag the widget into position your chosen position on your sidebar.

You will then  need to add the Java script code that Google or any other ads company  supplied you with when you created the advert.

Note: Add <div align=”center”;> at the start of the code & </div> at the end, this will help to centralize your advert in the sidebar.

It should be noted that by using the plugin I mentioned, you could add code from as many sources as you wish, including Amazon, Adsense, Clickbank etc. Each time the page is refreshed an advert will be chosen at random from the adverts you added to the plugin.

Adsense In The Content

This is where most people find problems, but before going into detail of how to achieve this, we need to first decide on the size of advert we wish to display;

(a) Use a 468 x 60 banner under the title of the article

(b) Use a 300 x 250 ad block at the top of the article

(c) Use a 250 x 250 ad block at the top of the article

Using a 468 x 60 banner

This is very straight forward if you install the plugin I have mentioned, simply insert the line of code in blue into the single.php code sheet of your theme.

<?php the_title(‘<h2>’, ‘</h2>’); ?>

<?php if (function_exists(‘dfrads’)) { echo dfrads(’4483472′); } ?>

<div class=”entry”>

<?php the_content(‘Read more…’); ?>

<div class=”clear”></div>


Add Google Adsense To WP Blog ContentThe  code  edit above will produce something similar to the image on the right.

This is very easy to set up & maintain & by adding code to the plugin from several different sources, you can ensure your adverts do not become stale & cause ad blindness in your readers.

This particular set up is also very well suited to narrow content areas as will be explained in the next section.


Using a 250 x 250 or 300 x 250 ad block


I’m combining (b) & (c) above as the process is identical, the only difference being the size of the advert to be placed in your content area.

Now it is fairly common knowledge amongst seasoned Adsense users, that large ads tend to do better than small ads, but this is only true of themes that can accomodate a large advert comfortably. Google themselves will actually tell you to experiment yourself to find what works best for your particular site. This is because Google understands that large ads on a narrow theme can actually be somewhat overpowering & thus have a negative impact on your readers.

As a rough guide I would say there are two formats to consider here;

1. Use a 300 x 250 ad block on a theme that has a content area width of 600px or more.

2. Use a 250 x 250 ad block on a theme that has a content area width of 550px or less.

The reason for this is that you don’t want your content to appear overpowered or swaped by adverts, if you use a 300 x 250 ad block on a theme that has a content area of 500px or less, then your ad block is going to take up 3/5ths of the available width & squeeze you text into a narrow band of only 180px wide when you allow for padding.

Use the following code example & insert the lines of blue text  into your themes single.php, as shown;

Code Example:

<div class=”entry”>

<div style=”float:right; padding-left:5px;”>

<?php if (function_exists(‘dfrads’)) { echo dfrads(’6374719′); } ?>


<?php the_content(‘Read more…’); ?>

<?php wp_link_pages(); ?>


Again you will see I have used the single line of php code from the plugin instead of having to mess around with big chunks of Java script from Google or any other advert provider. So what is the final outcome of our themes edited single.php code sheet..?

The Final Result

Add Google Adsense To WP Blog Content



Now if you look at both the banner under the title & the 300 x 250 ad block, both are displaying highly relevant adverts for the article that the ads have been placed in. Using this sort of set up you should see your Adsence earnings increase quite dramatically over the next couple of months. Once set up correctly you need do nothing more other than churn out your articles, the plugin & code we have added to the themes single.php code sheet, will take care of all your in content adverts from this point on.

Of course as always take backup copies of your single.php before editing, this way if you mess it up you always have the original code sheet to fall back on. If you get any problems adding Google Adsense to WP blog content, then by all means give us a shout in the comment box and we will be more than happy to try and help you out. Add Google Adsense To WP Blog Content

About Steve Nickson

Steve is a UK ex-pat currently living in the Philippines, he has been involved with computers for over 24 years, the last 7 years focusing on SEO & Social Media strategies, Web Promotion & Affiliate / Internet Marketing. He is constantly testing new ideas & is always keen to share his knowledge & expertise with fellow bloggers. Connect with Steve using the links below.
Add Comment Register

Leave a Reply


Steve NicksonHey guys,

we know your probably just as busy as we are, but we would really appreciate it if you could spare just a few minutes of your valuable time to like us on
Thank You