Adding or embedding AdSense ads or any type of script or code into a WordPress blog is pretty easy once you understand where to place it. In order to do that you first need to know what some of the code in your WordPress theme means. This WordPress guide will show you what some of the theme’s code means and where you can embed scripts like AdSense, HTML code or even images.
In order to edit your theme from within the WordPress dashboard, your themes files must writable. Do do that you need to change the permissions, or CHMOD of the themes files to at least 666 or 777. You could also work on them in the hosting accounts file manager or on your computer and FTP upload the changes files. I prefer to edit the theme from the dashboard.
Before you get started you should copy any file you are attempting to edit and save it in a text file on your computer. If anything goes wrong you can simply paste the unedited version back to undo any damage. You have been warned!
Starting from the top of the WordPress blogs main page, just above the post you can place your AdSense script like shown on this blog, a graphic, banner ad, both AdSense and a banner, or anything else for that matter. Keep in mind that Google will usually only show three AdSense blocks per page, so if you place AdSense into your WordPress theme and also in your posts and then in the sidebar, usually only the top three blocks will show. The remainder will be open space.
The place to add your code is in the main index template (index.php) and if desired can also be placed in the single post (single.php), page template (page.php), archives and if your theme has one the 404 template. Open one of the files and place your code just above the content which is code that looks like this:
Your Code Here <?php if (have_posts()) : //Are there any posts? ?>
Other places to place the code are: Below the post above or below the comments would be:
<?php if ( comments_open() ) : //if comments are allowed ?>
You can experiment with many different places, just be sure to backup any file you are attempting to edit, and that the AdSense code or banner fits in the area and that all HTML or script tags are properly closed. It would also be wise to view your changes in different browsers and different size windows to make sure it looks right.
For AdSense within a post, I use and recommend the AdSense Deluxe plugin, check out the guide for it here: How To Use The WordPress Plugin AdSense-Deluxe.