How to easily add AdSense to your WordPress posts
Send this article to a friend
Manually adding AdSense to WordPress posts is a relatively simple task that can be accomplished within just a couple of minutes. In this tutorial, we cover the process of adding the code to the singlepost.php. This will allow us to display advertisements on every post only when the post is individually viewed. There are many places within the singlepost.php to add the code, for the sake of simplicity, we are going to cover the hotspot.
The Process:
Step 1. Login to your AdSense account and create a new AdSense code. Either a 468x60 or 300x250 format should work fine.
Step 2. Login to your WordPress Administration panel
From the navmenu click Design->Theme Editor
From the list of theme files on the right, select your Single Post (single.php) file
Within the theme editor window, scroll down until you get to where it says <div class="entrytext">
Directly below <div class="entrytext"> add your AdSense code from step 1.
Step 3. (Optional) We can surround the code with a <div></div> tags. This will allow us to position the advertisment where we want it. See the example code below.
Left side placement example:
-
<div style="float:left;">
-
<script type="text/javascript"><!--
-
google_ad_client = "pub-XXXXXXXX";
-
google_ad_width = 300;
-
google_ad_height = 250;
-
google_ad_format = "300x250_as";
-
google_ad_type = "text_image";
-
google_ad_channel ="";
-
google_color_border = "FFFFFF";
-
google_color_bg = "FFFFFF";
-
google_color_link = "000000";
-
google_color_url = "000000";
-
google_color_text = "000000";
-
//--></script>
-
<script type="text/javascript"
-
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
-
</script>
-
</div>
Step 3. Click update file and go view your site!
If you want the ad to float right, change float:left to float:right. If you don't want to position the code left or right just surround your code with the <div></div> tags















