How to: Placing Adsense Strategically Between Posts

Greetings, fellow Probloggers (and those who aspire to be probloggers). It’s somewhat surreal to be posting here. Darren’s highlighted who I am pretty well (though I’m not sure where he dug up that photo!), so I’ll simply add that my strength lies in WordPress. I have been an active part of the WordPress development community for some time, so it will be natural to pass along some things I know from my experience with the platform. Some of the tips I write about will be very easy for some, and hopefully there will be entries that challenge even the most advanced. As long as someone is learning, I’m happy.

What is the plug in that you use to put the ads between the 2nd and 3rd post, or do you do so manually?

That, my friends, is the tip of the day. WordPress is a very flexible platform that allows for quite a bit of “munging” to make things work right. For starters, the basic building block of WordPress is a block of code called “The Loop”. It is called that because, literally, it is where the posts for a given page are “looped” through repeatedly to be displayed on the blog.

The standard Loop in the index.php file, is a block of code that might look a bit like this:

We begin processing the posts one by one as long as there are posts to display

This is, in fact, the absolute minimum that a Loop requires and it will get the job done. The blog won’t be much to look at, but it will display entries successfully. But how do we know where to put the Adsense code?

Here’s the trick: We can actually count how many times Loop has cycled and use that information to our benefit. That same block of code with a counter might look something like this:

Bam Bam Bigelow. That’s all there is to it. Drop your own Adsense code in there and you’re off to the races. Just as a precautionary note, make sure you place the if conditional and Adsense code before the end of the Loop. Most forms of the Loop end before endwhile, but there is a chance that your Loop doesn’t use this same format.

I hope this helps. Feel free to drop requests here in the comments. I’d love to tackle the issues that you as bloggers face and see if we can’t discover more ways to make our blogs sing.

Can anyone here help me figure out a way to only have ONE or TWO ads appearing in my main column after the first two pots?

My problem is that all THREE of my ads are appearing in the main column after posts, and an addition MIDDLE column I maid specifically for ads is EMPTY because the main column is using up all the ads I am allowed.

Can anyone help me find a way to limit how many ads are after my posts to lets say one or two?