How to Manually Place AdSense Ad Units in WordPress

Please note that I may earn a small commission from purchases made through product links in this article at no extra cost to you. I only recommend products that I have personally used and tested.

Contrary to what so many bloggers think, Google AdSense can still very much be a lucrative way of monetizing a website.

While ad management companies, such as AdThrive and Mediavine, are surging in popularity, doing it yourself with AdSense can often lead to great results.

In this article I am going to explain how you can manually add AdSense ad units in your content in a proper and clean way, so you can maximize your advertising earnings.

Why Place Ads Manually?

With AdSense, there are two ways to have ads placed on your site.

You can either choose to have Google automatically place ads throughout your site, where they seem fit, or you can place ads manually, where YOU want them to be.

I have always done this the manual way, because that has always given me the best returns. When you spend a bit of time working out which ad units and which locations work best, managing ads the manual way can be quite a lucrative affair.

So if you’re planning on joining an ad management company but you haven’t met their thresholds yet, or if you simply want to keep managing ads yourself, please read on.

How to Manually Place AdSense Ad Units

In short, I’m going to create a WordPress shortcode that allows you to easily add an AdSense ad unit to your content in a clean and manageable way.

In the example below I am using a 300 x 250 px display ad unit, because I find that ad unit offers the best returns.

1: Create an AdSense Ad Unit

The first step is to create an AdSense ad unit from within your Google AdSense dashboard.

In the Ads section, choose to create a new display ad:

In the next screen you can configure this new ad unit, which is really easy:

Select a fixed ad size with a width of 300 pixels and a height of 250 pixels. Also give this ad unit a good name, for example “display-fixed”.

Once you’ve done all that, you will get the ad unit code:

Copy and paste this ad unit code into a temporary text file.

2: Create a WordPress Shortcode

This is the exciting part, because we’re now going to create a WordPress shortcode with some PHP code.

We can write this code directly into the functions.php file, but my preferred way of doing this is with a plugin called Code Snippets. This plugin allows you to add simple pieces of code to your WordPress blog without touching the functions.php file.

The benefit of using Code Snippets is that the functions.php file (which is a super important theme file) remains untouched, and you can manage all custom code changes in one place.

In your WordPress dashboard, navigate to the plugins section, and install and activate the Code Snippets plugin:

Navigate to the plugin and choose Add New snippet. In the editor box, add PHP code as per below image, and give this snippet an appropriate name:

This is the copy/paste version of the code, where you will need to replace the words “ad unit code” by the actual ad unit code you picked up in the previous step:

Once you’ve created the code snippet and everything looks good, with no syntax errors, click Save Changes and Activate.

Congratulations, you’ve just created a WordPress shortcode.

3: Place Ad Unit in Content

The last step is the easiest, and most rewarding step. All you need to do now is add a WordPress shortcode in your content to display the AdSense ad unit.

Open a blog post in editor mode, and add the following shortcode wherever you want an ad unit to appear:

[content_ad]

You can do this in the Classic editor as well as in the Block editor.

When you test this, you may not immediately see an ad appear, because it can take some time for Google AdSense to sort this out for you.

Final Thoughts

That’s how easy it is to manually place AdSense ad units in your WordPress blog.

I recommend you place a display ad unit every 3 or 4 paragraphs, with each paragraph on average not longer than 2 sentences. This may sound like a lot of ads, but it’s actually pretty standard.

Also note that you can create different shortcodes for different ad units. I personally prefer to use the 300px by 250px display ad unit, but you’re free to experiment with whatever ad unit you like, and see what works best for your site.

​JOIN BLOG PIONEER

​​Subscribe now and learn how to grow your ​blog into a thriving business with effective SEO and monetization strategies.

Hi there, I’m AJ, a corporate IT nerd turned digital marketing pro, specializing in SEO and content strategy. I am using Blog Pioneer to help you achieve success online by sharing some of my knowledge and experience.Read more…