When I first started using Project Wonderful, my intention was to place a few of the 125x125 pixel ad spots in the top section of my sidebar. Initially I thought this would simply be a case of copying the code supplied by Project Wonderful, and pasting it into the appropriate spot within my WordPress theme. Unfortunately that wasn't the case. Pasting the Project Wonderful code directly into the theme resulted in the ad blocks failing to display.

After emailing Project Wonderful tech support, I was told that the only way they'd found to have the Project Wonderful ad blocks display properly on WordPress powered blogs was to paste the code into a text widget. Apparently there was some issue with php stripping out line breaks within the Project Wonderful code when returning the page, or something equally as technical sounding.

So, why didn't I just paste it into a sidebar text widget you ask? Whilst the theme I'm currently using is easy to "widgetize" I have preferred to hard code the sidebar so that I have more control over what sits where and how it displays. Hard coding has also allowed me to display different menu items and/or ads on different page types. Whilst I may one day fully widgetize the theme, I currently have no intention of doing so. This meant that if I wanted to use Project Wonderful on SwollenPickles.com I had to find a solution.

So, in case any one else is scratching there head, trying to figure out how to hard code Project Wonderful ad blocks into their WordPress blogs, here is the solution I found to get things up and running. If you aren't familiar with editing WordPress themes then what follows may be next to useless, for everyone else, I hope it makes some sense!

Step 1.
Create a straight html file and paste your Project Wonderful ad block code within it. Here is an example of what the code in that file could look like.

example code

Within the body tags you can also include any styles and sub headings you'd like to display with the ad block. Save the file with the html file extension. For the sake of this example, lets call the html file "project-wonderful.html".

Step 2.
Upload your html file to your server, taking note of the location you upload it to.

Step 3.
Modify your WordPress theme. Make sure you back up you blog and theme files before proceeding, just in case something screws up. It's unlikely, but then again, sometimes unlikely stuff happens, I mean, just look at the Spice Girls Reunion. Now figure out where you want your ad block to show up. Not all themes are the same, however a majority will have the following template files, header.php, sidebar.php, footer.php, index.php, single.php, page.php. Depending on where you want the ads to show up will depend on which file you'll need to edit.

For the sake of this example, we want to display the adds at the top of the sidebar, so open up the sidebar.php file in a text editor (eg. Notepad). Find the appropriate spot where you want the Project Wonderful code to appear and insert the following code:

Example Code

Change the section within the quote (") marks to reflect the location you uploaded your html file to.

Save your changes and go visit your site. With any luck you should now see the Project Wonderful adblock.

If anyone knows of a better solution, I'd be glad to hear it!