How to Add Google AdSense Between Posts in Wordpress

3 Steps to Add Google Adsense Ads to a Wordpress.org Blog

Saving Money versus Investing Money
Image Credit: Peter Dazeley / Getty Images

Google AdSense is one of the most popular ways to monetize your website. AdSense ads pay based on cost-per-click (CPC). Each time a visitor to your Wordpress blog clicks on an ad, you receive a fee. If you're using Wordpress.org and are hosting your blog through a third party, add Google AdSense ads to your blog to earn money. After you establish a Google AdSense account and are approved, you can begin adding ads to your site. Although many people use sidebar ads, you can also position ads between posts on your blog.

Warning: Before you make changes to your Wordpress editor screen HTML, it's a good idea to copy the original code and paste it into Notepad or a similar text-editor program. That way, if something goes wrong, you can delete all the code from Wordpress and replace it with the original code.

01
of 03

Enter HTML Code to Position AdSense Ads Between Posts

Add AdSense Between Posts in Wordpress Step 1
© Automattic, Inc.

To display Google AdSense image or text ads between your posts, log in to your Wordpress Dashboard, go into your theme Editor screen in the Appearance section, and open the index.php file located in the right panel. Enter this code in the center window of your editor screen:

<?php $count = 1; ?>

Position it directly above the code that says:

<php if (have _posts ()) : ?>.

(See the red circled locations in the accompanying image for clarity.)

You can change the number in the code from 1 (meaning the ad will appear beneath the first post on your blog) to any number you want in order to place the ad under the specific post on your blog where you want it to appear.

02
of 03

Enter the Google AdSense Code

Add AdSense Between Posts in Wordpress Step 2
© Automattic, Inc.

Open another browser window and log in to your Google AdSense account. Create the ad unit you want to appear between your posts on your blog and then copy that AdSense code provided by Google.

Return to your Wordpress dashboard window and paste your code in the same position as it is shown in the red circle in the accompanying image. It appears immediately before the line of HTML code that includes the --end .entry-- code.

Click the Update File button to save the changes.

03
of 03

View Your Blog

Add AdSense Between Posts in Wordpress Step 3
© Automattic, Inc.

View your blog to ensure the changes you made display the way you want them to. Note that a live ad might not appear immediately, but the position holder should be there right away. It can take Google a day or so to start displaying contextually relevant ads in a new ad unit.

Was this page helpful?