BlueHost Affilliate Random Ad Code for WordPress

BlueHost Affiliate Program members can place BlueHost ads on their WordPress blogs using the standard code on BlueHost’s Affiliate Links page, but what if you’d like to show a variety of images to help combat ad blindness? The following code selects a random ad image from a list and then injects that advertisement into your WordPress blog.

//
<DELETE_THESE_CAPSscript language="php">
//
// Your BlueHost Affiliate Account ID.
$acctID = "pixelwit";
//
// Text to be used if image not available.
$altText = "Check Out BlueHost";
//
// Link's title text.
$titleText = "Quaity Site Hosting Solutions";
//
//
//
// List of images to be rotated.
$img[] = "125x125/1.gif";// Image directory and name.
$trkCod[] = "blue";// Tracking code to be associated with this image.
//
$img[] = "125x125/2.gif";
$trkCod[] = "bluegreen";
//
$img[] = "125x125/3.gif";
$trkCod[] = "bluegradient";
//
$img[] = "180x150/1.gif";
$trkCod[] = "guy";
//
$img[] = "180x150/2.gif";
$trkCod[] = "girl";
//
$img[] = "125x240/2.gif";
$trkCod[] = "bluegreen125x240";
//
//
//
// Pick a random image and build the link.
$randI = rand(0, count($img)-1);
$txt1 = "<a href='http://www.bluehost.com/track/".$acctID."/";
$txt2 = "' title='".$titleText."' rel='nofollow'><img src='http://img.bluehost.com/";
$txt3 = "' alt='".$altText."'></a>";
echo $txt1.$trkCod[$randI].$txt2.$img[$randI].$txt3;
//
</script>
//

Here’s how to add random ads to your WordPress SideBar:

  • Login to your WordPress administration panel.
  • Navigate to “Presentation >>> Theme Editor”.
  • Select the “Sidebar” theme file to begin editing it.
  • Copy the contents of the Sidebar file and save it to a safe place (just in case).
  • Determine where you want your ads to appear in the sidebar. *It will probably need to be inside “Unordered List” (ul) and “Line Item” (li) tags.
  • Paste the above code into your sidebar file.
  • Delete the text at the beginning of the code that says, “DELETE_THESE_CAPS”. (This text was placed in the code so it would display properly on this blog.)
  • Change the $acctID variable from “pixelwit” to your BlueHost Affiliate ID.
  • Change the $altText and $titleText variables to suit your taste.
  • Use information from the BlueHost Affiliate Links page to edit the list of images. You can use as many or as few images as you like.
  • Once satisfied with the changes you’ve made, press the “Update File” button to save your modified sidebar file.
  • View your site and make sure everything works as expected.
  • If you have any problems, restore your Sidebar file using the text saved in step #4.

You can see this code at work in the bottom right corner of this blog. Refreshing the browser will probably display a different random BlueHost ad.

Let me know if you find this article useful.

2 Responses to “BlueHost Affilliate Random Ad Code for WordPress”

  1. David says:

    When I added the text, everything the Sidebar went away. Do I reloaded the original code.

    Instructions are easier said then done.

  2. Russ says:

    Great post about Bluehost and their affiliate program.

Leave a Reply

PixelWit.com's Comment Guidelines


Warning: Undefined variable $user_ID in /home2/pixelwit/public_html/blog/wp-content/themes/fvariant2/comments.php on line 57

You must be logged in to post a comment.

© Sean O'Shell 2007-2024