<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Plyplemadesign.com.au &#187; Blogging</title>
	<atom:link href="http://plyplemadesign.com.au/blog/category/blogging/feed/" rel="self" type="application/rss+xml" />
	<link>http://plyplemadesign.com.au/blog</link>
	<description>Website design, software programming and development, AMX control system programming, photography, graphics design, internet marketing</description>
	<lastBuildDate>Wed, 23 Feb 2011 04:48:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Add Google AdSense Under Post Titles</title>
		<link>http://plyplemadesign.com.au/blog/programming/how-to-add-google-adsense-under-post-titles/</link>
		<comments>http://plyplemadesign.com.au/blog/programming/how-to-add-google-adsense-under-post-titles/#comments</comments>
		<pubDate>Wed, 06 May 2009 12:59:18 +0000</pubDate>
		<dc:creator>Troy</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Adsense]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sem]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://plyplemadesign.com.au/blog/?p=55</guid>
		<description><![CDATA[In several of my blogs I have created for search engine optimization and marketing experimentation I have monetized them using the popular Google Adsense. One of Adsense&#8217;s limitations is that it is limited to only 3 ad units per page. These units need to be strategically positioned for maximum exposure and highest click through rate. [...]]]></description>
			<content:encoded><![CDATA[<p>In several of my blogs I have created for search engine optimization and marketing experimentation I have monetized them using the popular Google Adsense.  One of Adsense&#8217;s limitations is that it is limited to only 3 ad units per page.  These units need to be strategically positioned for maximum exposure and highest click through rate.  The position I choose is to have a letterbox unit positioned directly under the title of individual posts.  This means that a reader will have to view the ad before moving onto the content.  I also see a lot of questions on how to actually get the ads onto the site.</p>
<p>There are many plugins available to display Google Adsense on a WordPress blog but the one I choose to use is Simple Adsense Insertion (SAI).  To use this plugin you simply insert your Adsense campaign code into one of the SAI campaigns and then use the provided tags (<!- - wp_ad_camp_1 - -> or &#8220;echo show_ad_camp_1();&#8221;) to position them throughout your site.</p>
<p>To display an ad unit under the title of each post you will need to edit your themes template:<br />
<span id="more-55"></span><br />
1.  Go to you WordPress Admin page.<br />
2.  Download and install Simple Adsense Insertion using the built in plugin browser.</p>
<div id="attachment_56" class="wp-caption aligncenter" style="width: 596px"><a href="http://plyplemadesign.com.au/blog/wp-content/uploads/2009/05/sai.png"><img class="size-full wp-image-56" title="Simple Adsense Insertion Settings" src="http://plyplemadesign.com.au/blog/wp-content/uploads/2009/05/sai.png" alt="Simple Adsense Insertion Settings" width="586" height="125" /></a><p class="wp-caption-text">Simple Adsense Insertion Settings</p></div>
<p>3.  Go to the plugin settings for Simple Adsense Insertion and add in your Google Adsense code and copy down the tag for your campaign &#8220;echo show_ad_camp_1();&#8221; for example.</p>
<div id="attachment_57" class="wp-caption aligncenter" style="width: 176px"><a href="http://plyplemadesign.com.au/blog/wp-content/uploads/2009/05/editor.png"><img class="size-full wp-image-57" title="Theme Template Editor" src="http://plyplemadesign.com.au/blog/wp-content/uploads/2009/05/editor.png" alt="Theme Template Editor" width="166" height="366" /></a><p class="wp-caption-text">Theme Template Editor</p></div>
<p>4.  You now need to modify the templates to insert your campaign onto your site.  Browse to &#8220;Appearance &gt; Editor&#8221;</p>
<div id="attachment_58" class="wp-caption aligncenter" style="width: 207px"><a href="http://plyplemadesign.com.au/blog/wp-content/uploads/2009/05/templates.png"><img class="size-full wp-image-58" title="Theme Template List" src="http://plyplemadesign.com.au/blog/wp-content/uploads/2009/05/templates.png" alt="Theme Template List" width="197" height="346" /></a><p class="wp-caption-text">Theme Template List</p></div>
<p>5.  On the right hand side of the page you need to select the Main Index Template (index.php).  This is the main file for your public site so be careful not to modify the wrong thing.  If you are unsure on how to backup the file off an FTP then I recommend copying all of the text from the text-area into notepad and saving it for safe keeping.  If things go wrong you can always copy the text back.</p>
<p>6. The next step will vary slightly depending on the theme that you use and the way it outputs the posts.  You need to browse through the index.php file and find where the content of a post is sent to the browser.  The easiest to find this is use your browsers find function and look for &#8220;<em><span style="color: #3366ff;">the_content(</span></em>&#8220;.   This should be positioned in between a &lt;div&gt; tag with an id of something like &#8220;content&#8221;, &#8220;entry&#8221;, or &#8220;story&#8221;.  This is all theme dependant.</p>
<p>To display your ad unit before the post&#8217;s content  simply add &#8220;<em><span style="color: #3366ff;">&lt;?php echo show_ad_camp_1(); ?&gt;</span></em>&#8221; before &#8220;<em><span style="color: #3366ff;">the_content(</span></em>&#8221; but after the opening <em><span style="color: #3366ff;">&lt;div id=&#8221;content&#8221;&gt;</span></em>.<br />
7.  You can now save the changes to the file and have a look at the result on your home page.  There should be a Google Ad Unit displayed before the content of each post now.</p>
<p>One of the problems of adding the ad unit to each post is that Google only lets you display three units per page.  If you look at posts after the top 3 you will either have a large chunk of space or a non paying ad in its place, depending on your Google AdSense settings.</p>
<p>To get around this problem a counter can be added to the index.php inside the loop that makes the posts.  When this counter is less than 4 display a Google Ad, when it is equal or greater display nothing (without the large blank space) or display an ad from another affiliate.</p>
<p>Adding a counter is quite simple.  Firstly find the start of the loop used to display posts.  For most themes it will look something like</p>
<p><em><span style="color: #3366ff;">&lt;?php while (have_posts()) : the_post(); ?&gt;</span></em></p>
<p>Directly above  this line add the following code so it looks like this:</p>
<p><em><span style="color: #3366ff;">&lt;?php $totalPosts = 0; ?&gt;</span><br />
&lt;?php while (have_posts()) : the_post(); ?&gt;</em></p>
<p>To increment the totalPosts  counter add the following code directly under the opening of the while loop:</p>
<p><em>&lt;?php $totalPosts = 0; ?&gt;<br />
&lt;?php while (have_posts()) : the_post(); ?&gt;</em><br />
<em><span style="color: #3366ff;">&lt;?php $totalPosts++; ?&gt;</span></em></p>
<p>Now go down to where you added &#8220;<em>&lt;?php echo show_ad_camp_1();  ?&gt;</em>&#8220;.  Change this to:</p>
<p><em><span style="color: #3366ff;">&lt;?php<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if( $totalPosts &lt;= 3 )<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo show_ad_camp_1();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//add other ad campaigns here<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
?&gt;</span></em></p>
<p>If you have other ads to display that use php code then simply place that code inside the else statement {}.</p>
<p>Save these changes and go and look at your home page now.  It will no longer have blank spots or ugly unwanted ads on post four and after.</p>
]]></content:encoded>
			<wfw:commentRss>http://plyplemadesign.com.au/blog/programming/how-to-add-google-adsense-under-post-titles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

