In WordPress on the frontpage you have normally a flow of posts.
I want to show you how to put any advertising link or Adsense code between one or more of this posts.
We are going to edit the index.php for this, so please make a BACKUP of this file before starting to change anything!!
We will do this by setting a post counter in front of the loop
$postno = 1
inserting the add code inside the loop
if ($postno == 3) do stuff
and make the postcounter count up one digit for every post
$postno++;
In Detail:
Take the index.php of your theme and find:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
place the counter start between this two lines like this:
<?php if (have_posts()) : ?>
<?php $postno = 1; ?>
<?php while (have_posts()) : the_post(); ?>
as we are going to place to add codes after the first and the third post we find the next:
<?php endwhile; ?>
and insert my suggested code just above this endwhile:
<?php if ($postno == 1) { ?><div align="center" style="margin-bottom: 10px;">
AdSense Code below post No. one replace with your code
</div><?php } ?>
<?php if ($postno == 3) { ?><div align="center" style="margin-bottom: 10px;">
AdSense Code below post No. three replace with your code
</div><?php } ?>
<?php $postno++; ?>
I styled this code to center on the page and give some space below, you are free to remove or change this div style.

There are some themes like Arthemia by Michael Jubel which use an other query for posts, so you will not be able to find the if (have_posts()) : part in there.
In a query like in that theme you should look for:
<?php
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("cat=-27,-28&paged=$page&posts_per_page=5"); ?>
<?php $postno = 1; ?>
<?php while (have_posts()) : the_post(); ?>
and place the counter start before while (have_posts()) : the_post(); – I did this here already.
The code to call the add code and count up one by one (as before) is placed in the same way as in default theme before the next endwhile; after the div before, it should look like this:
<?php the_excerpt(); ?>
</div>
</div>
<!-- new code start -->
<?php if ($postno == 1) { ?><div align="center" style="margin-bottom: 10px;">
AdSense Code below post No. one replace with your code
</div><?php } ?>
<?php if ($postno == 3) { ?><div align="center" style="margin-bottom: 10px;">
AdSense Code below post No. three replace with your code
</div><?php } ?>
<?php $postno++; ?>
<!-- new code end -->
<?php endwhile; ?>
<div class="navigation">
happy coding…
Adsense between some Posts Wordpress AdSense manages all aspects of Google AdSense for your blog: insert ads into posts This seems to be a problem with some WordPress sidebars) there may be conflicts between add In WordPress on the frontpage you have normally a flow of posts. I want to show how put any advertising link or Adsense code between one more this We are going edit index.php Placing am going to do is show you how to easily place ads (or other content) . not want to display Ads but Affiliate Banner or any other contents in your I would assume that of how to add to test Tags: adsense, between, your, blog, are intended for use by a small group of of code to make the plug in work in your How to Embed Google Within on
Search terms:
August 28, 2010 um 19:30 Uhr
Hello JW,
i put the adSense-Code in my theme and it looks great! Thanks so much for this helpful infos.
ONE QUESTION:
I am a coding beginner, so please tell me , how can i manage it that THREE AdSenseAds are displayed?
sincerly
M.
September 17, 2010 um 00:23 Uhr
Hey JW, Great tutorial, best one out there yet. Problem, my client has 20 posts and want’s ads always in between them. I added the code like so.
Obviously this one in between how you said
and then the ads as follows. But I’m only getting 3 ads. The rest are not showing up. What am I doing wrong?
Thanks
September 17, 2010 um 08:27 Uhr
I show how to put two (2) ads between your posts.
Google adsense says here: https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=9735
This limit applies automatically if you try to put more ads in, that’s what you are doing wrong.
My code above just gives you the chance to count your posts and insert only two ads between your posts.
September 17, 2010 um 00:24 Uhr
Actually I just noticed that script is not allowed I guess. Hit me up for the code and I’ll show you.
Thanks
September 17, 2010 um 08:25 Uhr
That script is just one of many ways to insert only an allowed number of ads to your site. Who says that this is not allowed?