<?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>Poiesis Web Development &#187; the loop</title>
	<atom:link href="http://www.poiesis.co.za/index.php/tag/the-loop/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.poiesis.co.za</link>
	<description>Because IT matters</description>
	<lastBuildDate>Thu, 18 Aug 2011 16:35:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Adding Adsense code to your blog</title>
		<link>http://www.poiesis.co.za/index.php/2009/08/adding-adsense-code-to-your-blog/</link>
		<comments>http://www.poiesis.co.za/index.php/2009/08/adding-adsense-code-to-your-blog/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 15:41:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[$wp_query->post_count]]></category>
		<category><![CDATA[Google Adsense]]></category>
		<category><![CDATA[have_posts()]]></category>
		<category><![CDATA[index.php]]></category>
		<category><![CDATA[the loop]]></category>

		<guid isPermaLink="false">http://www.poiesis.co.za/?p=113</guid>
		<description><![CDATA[There are a number of plugins you can use to add Google Adsense to your blog. Unfortunately, most of them have very little flexibility when it comes to the positioning of the ads. But fret not; there are a few hacks you can use to hard code the Adsense code to your blog. These hacks [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.poiesis.co.za/wp-content/uploads/2009/06/wordpress-150x150.gif" alt="WordPress" title="WordPress" width="150" height="150" class="alignleft size-thumbnail wp-image-70" />There are a number of plugins you can use to add Google Adsense to your blog. Unfortunately, most of them have very little flexibility when it comes to the positioning of the ads. But fret not; there are a few hacks you can use to hard code the Adsense code to your blog. These hacks are applied to your theme.</p>
<p>The obvious place to have your Adsense is on your home page. In this post, we&#8217;ll look at inserting Adsense on your hope page. This would be in the loop in the <code>index.php</code> page. As you can guess, it will also be applied to other pages that use the loop, namely the various archives pages.</p>
<p>Let&#8217;s begin:</p>
<p>Open the <code>index.php</code> file of your theme and find the line <code>&lt;?php if ( have_posts() ) : ?&gt;</code> and add the following just <strong>before</strong> this line:</p>
<p><code>&lt;?php<br />
&nbsp; &nbsp; $postnum = 1;<br />
&nbsp; &nbsp; $showadsense1 = <em>n1</em>;<br />
&nbsp; &nbsp; $showadsense2 = <em>n2</em>;<br />
&nbsp; &nbsp; $showadsense3 = <em>n3</em>;<br />
?&gt;</code></p>
<p>Just change <em>n1</em>, <em>n2</em>, and <em>n3</em> to whatever posts you want the Adsense to appear after. So if you want it to appear after the 1st, 4th and 8th posts, just change it to 1, 4 and 8 respectively. Also, if you only want one Adsense unit in the loop, discard the lines: <code>$showadsense2 = n2;</code> and <code>$showadsense3 = n3;</code>.</p>
<p><span id="more-113"></span>Next, scroll down to the line <code>&lt;?php endwhile; ?&gt;</code> and add the following code just <strong>before</strong> it:</p>
<p><code>&lt;?php if ($postnum == $showadsense1) {<br />
&nbsp; &nbsp; echo '<br />
&nbsp; &nbsp; &nbsp; &nbsp; Your adsense code<br />
&nbsp; &nbsp; ';<br />
} ?&gt;</p>
<p>&lt;?php if ($postnum == $showadsense2) {<br />
&nbsp; &nbsp; echo '<br />
&nbsp; &nbsp; &nbsp; &nbsp; Your adsense code<br />
&nbsp; &nbsp; ';<br />
} ?&gt;</p>
<p>&lt;?php if ($postnum == $showadsense3) {<br />
&nbsp; &nbsp; echo '<br />
&nbsp; &nbsp; &nbsp; &nbsp; Your adsense code<br />
&nbsp; &nbsp; ';<br />
} ?&gt;</p>
<p>&lt;?php $postnum++; ?&gt;</code></p>
<p>Obviously, you need to replace <code>Your adsense code</code> with your adsense code. If you only want one Adsense unit, discard the second and third bits of php code.</p>
<p>That&#8217;s it, just upload the altered <code>index.php</code> page to your theme folder and your Adsense will be enabled. </p>
<p>Maybe you don&#8217;t want Adsense to appear on archives pages that have only one post as that might look MFAish? Not a problem, just show Adsense from the second post onward. Alternatively, you can filter out archive pages that have a post count of 1 by using <code>$wp_query->post_count</code> in the first bit of php code that inserts your Adsense code. In other words, you&#8217;d replace the code that you inserted before the line <code>&lt;?php endwhile; ?&gt;</code> with the following:</p>
<p><code>&lt;?php if ($postnum == $showadsense1) {<br />
<strong>&nbsp; &nbsp; if (($wp_query->post_count) == 1) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo ' ' ; }<br />
&nbsp; &nbsp; else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo '<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Your adsense code<br />
&nbsp; &nbsp; &nbsp; &nbsp; ';<br />
&nbsp; &nbsp; }</strong><br />
} ?&gt;</p>
<p>&lt;?php if ($postnum == $showadsense2) {<br />
&nbsp; &nbsp; echo '<br />
&nbsp; &nbsp; &nbsp; &nbsp; Your adsense code<br />
&nbsp; &nbsp; ';<br />
} ?&gt;</p>
<p>&lg;?php if ($postnum == $showadsense3) {<br />
&nbsp; &nbsp; echo '<br />
&nbsp; &nbsp; &nbsp; &nbsp; Your adsense code<br />
&nbsp; &nbsp; ';<br />
} ?&gt;</p>
<p>&lt;?php $postnum++; ?&gt;</code></p>
<p>There&#8217;s no need to alter the second and third iterations of the Adsense code as these won&#8217;t appear anyway if there&#8217;s only one post.</p>
<p>In our next post we&#8217;ll look at creating a short code to insert Adsense in your posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.poiesis.co.za/index.php/2009/08/adding-adsense-code-to-your-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Next-Previous link not showing?</title>
		<link>http://www.poiesis.co.za/index.php/2009/06/next-previous-link-not-showing/</link>
		<comments>http://www.poiesis.co.za/index.php/2009/06/next-previous-link-not-showing/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 18:24:13 +0000</pubDate>
		<dc:creator>Brent</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[posts_nav_link]]></category>
		<category><![CDATA[the loop]]></category>

		<guid isPermaLink="false">http://www.poiesis.co.za/?p=65</guid>
		<description><![CDATA[We&#8217;ve received a few queries about the next/previous link in our WordPress themes from people wanting to know how to implement it in their themes. Well, the answer is simply insert the posts_nav_link() template tag into the php files of your theme that has the if ( have_posts() ) : while ( have_posts() ) loop. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.poiesis.co.za/wp-content/uploads/2009/06/wordpress-150x150.gif" alt="WordPress" title="WordPress" width="150" height="150" class="alignleft size-thumbnail wp-image-70" />We&#8217;ve received a few queries about the next/previous link in our <a href="http://www.poiesis.co.za/index.php/category/wordpress-themes/">WordPress themes</a> from people wanting to know how to implement it in their themes. Well, the answer is simply insert the <code>posts_nav_link()</code> template tag into the <code>php </code>files of your theme that has the <code>if ( have_posts() ) : while ( have_posts() )</code> loop. These files include index.php and archive.php. When you use the <code>posts_nav_link()</code> tag the next/previous links are generated automatically when required. However, the tag only works for pages of posts.</p>
<p><span id="more-65"></span><br />
<h2>So where do you insert the <code>posts_nav_link()</code> tag?</h2>
<p>You insert it after the loop. In other words, after the <code>&lt;php? endif; &gt;</code> towards the bottom of the file.</p>
<p>If you want to find out more about the <code>posts_nav_link()</code> tag visit the following WordPress pages:</p>
<ul>
<li>http://codex.wordpress.org/Template_Tags/posts_nav_link</li>
<li>http://codex.wordpress.org/Next_and_Previous_Links</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.poiesis.co.za/index.php/2009/06/next-previous-link-not-showing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

