Advertisements after first post in WordPress
Here is a simple way to put an AdSense ad, or any other ad for that matter, after the first post in your WordPress blog. This will only work on your main page, not on an individual post page.
Okay, let’s get started. Open up your index.php file or go into the WordPress control panel > Presentation > Theme Editor and choose Main Index Template on the right
Find the line that starts with:
<?php if (have_posts())
Add this line of code above it:
<?php $count = 1; ?>
Find the line that starts with:
<?php the_content
Add this code below its closing tag:
<?php if ($count == 1) : ?>
Your Google AdSense code
<?php endif; $count++; ?>
Upload and update everything and see so everything works. You can easily customize this spot using CSS. You can also publish the advertisement after the second post or the third etc. Just change:
“count == 1? to “count == 2?

One Response
Express yourself. Tell us your opinion. Make a comment!
Nice post. Just to add, if you wanted to have the advert after both the first AND the second post change count==2 to count<=2
Jim
Write your comment