How to wrap text around advertising block

I’ve been looking at my AuctionAds & Adsense advertisement placements on this blog, and wanted to see how I could improve the “blending”. I’ve seen a few sites where the blog entries wrap around the ad block, and wanted to do something similar. It turns out that the code is pretty simple!

In single.php (the file may be of a different name, depending on your theme… for example Redoable’s is single_post.php), find:

<?php the_content(); ?>

And add this above it:

<div style=”float:left;margin-right:10px”>
Your Adsense code goes here
</div>

Basically, you use a <div> block that “floats” (meaning that it allows text to wrap around it). You can change the float:left to float:right if you want it on the right side.

Making AuctionAds a little more Wordpress friendly

If you’re a Webmaster, and haven’t signed up for AuctionAds yet, you should. Basically it is an advertising network for the eBay affiliate program: The AuctionAds advertisement shows an item listed on eBay, if one of your viewers click on the ad and end up buying that item, you get a commission.

There is one problem with AuctionAds though. And that is, unlike Google Adsense’s ability to “read” the page and present contextual and relevant ads, AuctionAds has a “simple” parameter where you must enter keywords. So if you want AuctionAds to show Cell Phone listings on eBay, you need to enter “Cell Phone” into that field. While it allows the webmaster an ability to “focus” the ad, it’s rather tedious… you can’t enter one code, and expect that the ad will always be relevant. Maybe if your website was just about Cell Phones, that’d be cool. But if, for example, you’re using on a general blog where you post about a variety of topics, there’s no “simple” way to make the ad relevant.

To that end, I’ve written some simple code to work around that deficiency…

In single.php, find:

<?php the_content(); ?>

And add this above it:

<?php
$catname = ”;
foreach((get_the_category()) as $cat) {
$catname = $catname . $cat->cat_name . ‘,’;
}
$catname = rtrim($catname,’,');
?>
<script type=”text/javascript”><!–
auctionads_ad_kw = “<?php echo $catname; ?>”;
… your auctionads parameters …
–></script>
<script type=”text/javascript” src=”http://ads.auctionads.com/pagead/show_ads.js”>
<script>

What the code does is:

  • AuctionAds is to appear on each post: when you read the single blog post, you will call single.php (or whatever your theme calls it… Redoable calls it single_post.php).
  • Because I file all my blog posts in various Wordpress Categories, it’s relatively simple to identify the focus of each post.
  • Using PHP code, I extract the full category list for that specific post, and insert those words into the AuctionAds keyword field. Thus ensuring that AuctionAds presents auctions relevant to the topic of the blog post.

This is what I learnt today! Hopefully it’ll be of use to others :)

Finally a real alternative to Google Adsense

For those that haven’t heard of Shoemoney yet, this picture that will explain more than words ever will (Hint: Adsense pays monthly).
Shoemoney with Adsense check

Anyway, Shoemoney founded an ad network which is is a realistic rival to Google’s Adsense. AuctionAds is basically a dynamic banner which lists relevant auctions on eBay! I’m using it as the top banner of the home page. This blog doesn’t get that much traffic, but I’ve got it placed on a few other sites, so we’ll see how that pans out!

June Namecheap discount coupon

Here’s the Namecheap discount coupon for new domain registrations in June. If you enter junebugz it gives a 10% discount for the order.

Wordpress memory errors

I just upgraded to the latest version of Wordpress (2.1.3).

Before the upgrade, I started to get strange errors (admin screens not painting correctly). And when I attempted the upgrade, I received this error:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 71797 bytes) in /[path]/upgrade.php on line 155

I believe the memory leak is originating from Arne Brachhold’s Google Sitemaps plugin. To be fair, I was running 2.7.1 (a reasonably old version). Will upgrade and hope the problem goes away.