How to add AdSense ad unit to WordPress blog?

SHARE

Every blogger knows about the Google AdSense program. It is the first monetization strategy that is adopted. Not that it is the only one, there are some noteworthy alternatives but Google AdSense is the top choice. You can place the AdSense ad unit anywhere on your blog, but there are some placement recommended by Google and other top bloggers that has yielded more earnings. One of the recommended placement is above the fold. Above the fold refers to the screen area that is visible without scrolling. It is recommended to place an AdSense ad unit just above the post and below the title. In this post, we will learn how to add AdSense ad unit to WordPress blog below the title and above the post. This customization is done on the Twenty Thirteen WordPress theme but can be applied to any other theme as well.

Add AdSense ad unit to WordPress blog

To place the AdSense ad unit, you need to get the code. It is assumed that you have an AdSense account and know how to get the code. In case you do not have an AdSense account, you can opt for other alternatives like Chitika or Kontera. Let us take a look on how to add AdSense ad unit to WordPress blog.

  • Login to your WordPress dashboard.
  • Click on Appearance –> Editor.
  • Click on the content.php file. Never modify the original theme file. Always create a child theme to customize your theme files.
  • Copy and paste your AdSense ad code after the following line,
<div>
<?php if ( is_single() ) : ?>

The ad will not be centered by default. To center the ad, wrap the ad code in a <div> tag and style it using an id.

Your final code should look like below,

Add AdSense ad unit to WordPress blog

  • Save the content.php file.
  • Now edit the style.css file.
  • Add the following lines to it,
#Adsense468x60{
display: block;
margin-left: auto;
margin-right: auto;
width:468px;
}
  • Save the file.

The above css code will center the ad unit.

And that is it. Your AdSense ad unit should appear right before your post and after your post title. Do let me know if you are not able to get it right and I will be glad to help.

Your turn?

  • How long have you been AdSense?
  • Which is your best ad placement location?
  • Has it helped your earnings?

Do let me know your thoughts through the comment section.

If you found this post helpful and informative, please share it using the share buttons above.

4 thoughts on “How to add AdSense ad unit to WordPress blog?

  1. I found this post very useful.actually I was earlier using blogger for my blog and around 2 years back started using wordpress after taking help from a professional.I did not how to place adsense in wordpress,i used to take help from him…Your post made it easy for me,now i can change my adds more easily….

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>