- Getting Started with Google AdSense
- Adding Google AdSense Ads to a Sidebar Widget
- Adding Google AdSense Ads Within the Page
Adding Google AdSense Ads Within the Page
You may like to place ads above the first post on a page, or perhaps below a post or near the footer. To do that, you need to edit the Theme files.
One approach is to add the code directly into the relevant Theme file, such as in single.php, index.php, header.php, or footer.php.
Another option is to enter the code in a separate file, perhaps named ad-top.php or ad-bottom.php, stored in the Theme folder, and then include that file into the theme file. This technique has the advantage of keeping the AdSense code clearly discrete, and makes it easier to move or edit the ads or replace them later.
Include the ad file into the appropriate theme file (probably index.php or footer.php) with coding like this:
<?php include (TEMPLATEPATH . "/ad-top.php"); ?>
This code line assumes that your newly created ad-top.php file is in the same directory as all the other theme files.
Remember to validate your blog after adding the code, just to make sure that you haven't messed things up. Visit your blog and test to see if things are working correctly (see Figure 5).
Figure 5 My KnowIT blog has one ad above the content and a short stack of ads on the right side.
Ads may not be appropriate for your topic or your audience, but if they are then you can probably earn at least a bit of pocket money, and perhaps cover hosting costs. If your blog is wildly popular and you work hard at it, you may become one of the few who can actually earn a decent income from ads in the blog. In either case, Google AdSense ads are easy to implement. Why not give them a go?
Visit Miraz' KnowIT blog to read more of her writings about WordPress, Macs, technology, and the Internet.