putting advertisement blocks on a blog

Earlier, my AdSense ads were hardcoded into my WP template files. But now I want to experiment with other ads. I need to rotate the ads often, and the old solution isn't satisfactory. Here is a short list of the requirements:

* admin interface to define HTML code of ads
* define ad areas
* assign ads to the ad areas
* optionally: assign a probability to each ad

Surprisingly, the solution is exists: WPAds is a simple, but powerful tool. It has everything what I need. Installed.

I defined three ad areas on my blog:

* sidebar
* after post
* inside the post, after the target for the link "Read the rest of this entry"

The placement of the first area is defined in the file "sidebar.php":

<?php if (function_exists('wpads')) { wpads('sidebar'); } ?>

In the same way, the second area is placed in the file "single.php".

Placing the third area is more tricky. I'll talk about it later.

Vibe code with your voice

Stop fighting speech recognition.
Just talk → fix mistakes later

"... _brings_ hello world"   ❌
          ↓
"... _prints_ hello world"   ✅

Get handsfree.vc on Google Play

Categories: blogging

Updated: