Recently, I was working on a client’s project and one of the requirements he had was the ability to insert Google AdSense anywhere in the WordPress posts.  Many website owners that rely on Google AdSense for revenue usually want the ads to appear at specific places that they want.

There are a number of plugins you can use to insert Google AdSense in your WordPress posts. However, the problem with using too many plugins is that they can slow down your site and sometimes, they may be incompatible with the WordPress version that you are using.

In this post, I will show you how you can easily show Google AdSense ads on your website without a plugin. The process is simple and even if you have not hacked WordPress before, you should be able to do this. So, let’s dive in.

WordPress Google AdSense Plugins

If you search the WordPress library, you will find many plugins you can use to add Google AdSense in your WordPress site. However, most plugins allow you to show Google AdSense ads in your post or on the sidebar through a widget, for example, somewhere between the paragraphs of your post (See example below)


However, where you place your ads can affect your CTR (Click-through rate) and in-between paragraphs is not the best place. Studies have shown that ads that receive the highest CTR are located above the fold, either on the right or left side of the article. Darren Rowse of Problogger did an interesting experiment where he was able to get a 40% increase in CTR simply by changing the Ad positions.

To increase your AdSense revenues, you should place your ads on the top-left or to-right corner of the post.  To do this, we will use a WordPress shortcode. Let’s get started

Creating the Shortcode

Log into the WordPress Dashboard, go to Appearance and click Editor. Then, select the functions.php  file and scroll to the end of the code. We want to add the shortcode that will show Google AdSense in our posts. Add the following code below the final line in your functions.php  file:


Then, click Update.

Show AdSense Ads anywhere in your WordPress Posts

That is all that you needed to do. Surprised how easy it was? Now you are ready to show ads on your post. To do this, simply write the following code where you want the ad to appear:


You can place the code in between paragraphs, top-left, top-right or anywhere else you would like Google to show ads on your site. The code can be used on either posts or pages.

Styling your Ads

If you wish to style the AdSense code, you can do so in your style.css file. Look for the code with the div element #googleadsense and style it the way you want.


Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS