Creating AdSense Widgets in WordPress

December 11, 2007

Recently I attempted to create a WordPress widget for an AdSense Firefox referral image ad in a widget-ready theme. I was quite surprised how easy it was. It may not be the best code ever, but it got the job done. Here is a quick run-down of how I did it.

Assuming you already have the Google AdSense unit code, create a file like <root directory>/wp-content/themes/<specific theme>/widgets/ff_ad.php and put your unit code in it. You will probably have to create the widgets directory under your specific theme. So the AdSense code in ff_ad.php should look something like this:

ff_ad1.png

Then in the <root directory>/wp-content/themes/<specific theme>/function.php, add this:

functions.png

At this point, the widget should show up in the list of available widgets for the theme.

Thats it.

Leave a Comment

Previous post:

Next post:

Run Level Media CMS Tracking