Adding AdSense to WordPress category and archive results

This tutorial explains how to add Google AdSense ads to your WordPress category and archive listing result pages. Although there are plugins available to do this, it's nice to to have full control over how and where your ads are placed. The process is fairly simple and you should be able to implement the ad placement within just a few minutes.

How to add ads to category and archive results:

1. Log into your WordPress admin panel
2. Select Presentation ->Theme Editor from the navigation menu
3. From the theme editor select the archive.php from the list to the right
4. Find the following line

<?php if (have_posts()) : ?>

5. Above it add the following line

<?php $count = 1; ?>

6. Now find the following line

<div class="entry">

7. Add the following below it (replace AdSense Code with your code)

<?php if ($count == 1) : ?>

AdSense Code

<?php endif; $count++; ?>

8. Click update file and go test your site to see if the ads are displaying on the category results page for a particular category.

Note: To change which post result your ad is placed under, simply change the count number.

Example: $count == 3 would place the ad under post 3 on the results page.