How to put ads between posts in WordPress v1.5
I have a WordPress powered website and I have been trying to find a simple way to place my Google Ads between the first and second post on the front page for a while now, struggling to find a solution, I created one myself. This doesn’t necessarily have to be an advertisement, it can be anything and will be placed between Post 1 & Post 2 on your WordPress index.
Step 1
Using the Theme Editor in the Presentation section of the WordPress Admin, or using a text editor open up the Main Template file (index.php) and find
<?php get_header(); ?>
Add after:
<?php $postnum = 1; $showads = 1; ?>
Step 2
Find (including everything in-between the p tag):
<p class="postmetadata">...</p>
Add after:
<?php if ($postnum == $showads) { ?>
This text will be placed after the first post and before the second post only. Nowhere else on the index page.
<?php } $postnum++; ?>
Then simply place your Ad code or the content of your choice into the area mentioned in the above piece of code
Credit where credit is due.
I do not take credit for the code, I pulled it from other sources and had to fiddle with it to get it to work in WordPress v1.5.