How to add AdSense ad unit to WordPress blog?

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,
<?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,
display: block;
margin-left: auto;
margin-right: auto;
  • 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.

5 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….

  2. Hello, I am struggling to add Ad units to my blog, as I’m not quite sure where to add the code.
    I am trying to add a 160×600 ad unit as well as a 728×90 ad to all my blog posts.

    Thanks for your help.

Leave a Reply

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