<?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>Atomic Playboy&#187; PHP</title>
	<atom:link href="http://atomicplayboy.net/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://atomicplayboy.net</link>
	<description>All hail the mushroom cloud</description>
	<lastBuildDate>Sat, 22 May 2010 19:43:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Canonical URLs in WordPress</title>
		<link>http://atomicplayboy.net/blog/2009/03/05/canonical-urls/</link>
		<comments>http://atomicplayboy.net/blog/2009/03/05/canonical-urls/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 16:26:50 +0000</pubDate>
		<dc:creator>Johan Svensson</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://atomicplayboy.net/?p=650</guid>
		<description><![CDATA[Like any good obsessive-compulsive blogger, I frequently pour over my web site statistics looking for interesting stuff. One thing that caught my eye is that search results coming in from Google tends to link to threaded comment pages for entries. For example, I&#8217;d get hits to /blog/2009/03/05/entry-slug/comment-page-1/, which is an URL that&#8217;s pretty hard to [...]]]></description>
			<content:encoded><![CDATA[<p>Like any good obsessive-compulsive blogger, I frequently pour over my web site statistics looking for interesting stuff. One thing that caught my eye is that search results coming in from Google tends to link to threaded comment pages for entries.</p>

<p>For example, I&#8217;d get hits to <tt>/blog/2009/03/05/entry-slug/comment-page-1/</tt>, which is an <span class="caps">URL </span>that&#8217;s pretty hard to actually find on the page &#8212; it&#8217;s only used for permanent links to entry comments, with an anchor to the comment ID tacked on, <a href="http://atomicplayboy.net/blog/2009/02/23/spotify-bay/comment-page-1/#comment-49949">like this</a>.</p>

<p>What I&#8217;d prefer to see is incoming hits to the actual blog entry <span class="caps">URL </span>&#8211; <tt>/blog/2009/03/05/entry-slug/</tt> in this case. Luckily, there&#8217;s a smart and simple solution &#8212; canonical <span class="caps">URL</span>s. The Google Webmaster blog <a href="http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html">explains it nicely</a> with examples.</p>

<p>So I simply add a canonical tag referencing the preferred <span class="caps">URL </span>in each page. Now, it&#8217;s just the <em>preferred</em> <span class="caps">URL </span>on my side &#8212; this is just a hint to search engines that tells them that this page is a duplicate, and that I&#8217;d prefer them to let results point to one particular page of these duplicates. In 99% of the cases it will be respected, though.</p>

<p>The actual code is just a few lines. Add this in <tt>header.php</tt> of your theme, somewhere in the head:</p>




<pre><code>
&lt;?php if (is_singular()) { ?&gt;
&lt;link rel="canonical" href="&lt;?php the_permalink() ?&gt;" /&gt;
&lt;?php } ?&gt;
</code></pre>




<p><tt><a href="http://codex.wordpress.org/Conditional_Tags#A_Single_Page.2C_Single_Post_or_Attachment">is_singular</a></tt> is a function that returns true if any of <tt>is_single()</tt>, <tt>is_page()</tt> or <tt>is_attachment</tt> return true &#8212; in other words, if you&#8217;re currently visiting a single entry, a page or an attachment.</p>

<p>With this, each entry sub-page of comments has the main entry <span class="caps">URL </span>as their canonical <span class="caps">URL.</span> Now to wait a few days and see when the search engines<sup class="footnote"><a href="#fn1">1</a></sup> pick up the change.</p>

<p class="footnote" id="fn1"><sup>1</sup> And by &#8220;search engines&#8221; I mean &#8220;Google.&#8221;</p><script src="http://feeds.feedburner.com/~s/AtomicPlayboy?i=http://atomicplayboy.net/blog/2009/03/05/canonical-urls/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://atomicplayboy.net/blog/2009/03/05/canonical-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A New Hope</title>
		<link>http://atomicplayboy.net/blog/2006/05/07/a-new-hope/</link>
		<comments>http://atomicplayboy.net/blog/2006/05/07/a-new-hope/#comments</comments>
		<pubDate>Sun, 07 May 2006 01:55:43 +0000</pubDate>
		<dc:creator>Johan Svensson</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Kestrel]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://atomicplayboy.net/blog/2006/05/07/a-new-hope/</guid>
		<description><![CDATA[Wherein the author attempts to create a new Wordpress theme.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a long time, but I&#8217;ve started fiddling a bit with web design again. While I do like <a href="http://getk2.com/">K2</a>, I prefer to make my own design. And K2 was always meant to be temporary here until I found my long lost design groove again. And I <em>think</em> I spotted it out in the gutter, drunk out of its mind. It&#8217;s in rehab now.</p>

<p>I&#8217;ve started work on a <a href="http://wordpress.org/">WordPress</a> theme tentatively called <strong>Kestrel</strong>. I&#8217;m writing the basic layout now with <a href="http://codex.wordpress.org/Theme_Development">the theme development</a> page readily available in another tab.</p>

<p>I do admit that it feels a bit messy to use pure <span class="caps">PHP </span>instead of a template language like <a href="http://movabletype.org/">Movable Type</a> uses, but I&#8217;ll manage.</p>

<p>Since doing live editing gets messy I&#8217;ve set up a local web server hosted on my file server. <a href="http://lighttpd.net/">lighttpd</a> as web server, <span class="caps">PHP </span>and MySQL.</p>

<p>lighttpd is <em>very</em> nice for local development &#8212; it doesn&#8217;t include the entire kitchen sink like Apache does. It took a bit of work to get it going the way I wanted, though. For a while it decided to send me the <span class="caps">PHP </span><em>source code</em> instead of passing it on to <span class="caps">PHP </span>&#8211; but only when I accessed a <span class="caps">PHP </span>file from my workstation. When viewed locally it worked properly.</p><script src="http://feeds.feedburner.com/~s/AtomicPlayboy?i=http://atomicplayboy.net/blog/2006/05/07/a-new-hope/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://atomicplayboy.net/blog/2006/05/07/a-new-hope/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Like, switch!</title>
		<link>http://atomicplayboy.net/blog/2003/02/05/like-switch/</link>
		<comments>http://atomicplayboy.net/blog/2003/02/05/like-switch/#comments</comments>
		<pubDate>Wed, 05 Feb 2003 10:31:51 +0000</pubDate>
		<dc:creator>Johan Svensson</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://atomicplayboy.net/blog/2003/02/05/like-switch/</guid>
		<description><![CDATA[Yup. Took me all of fifteen minutes to make a quick PHP hack that points you to different style sheets. It&#8217;s in the bottom part of the sidebar. Currently only two styles available, but I&#8217;ll make more, you can count on that&#8230; I&#8217;m already getting tired of Warranty Void, the latest one. I always pick [...]]]></description>
			<content:encoded><![CDATA[<p>Yup. Took me all of fifteen minutes to make a quick <span class="caps">PHP </span>hack that points you to different style sheets. It&#8217;s in the bottom part of the sidebar. Currently only two styles available, but I&#8217;ll make more, you can count on that&#8230; I&#8217;m already getting tired of Warranty Void, the latest one.</p>

<p>I always pick strange names for my style sheets. The next one will be called Nuisance Value.</p><script src="http://feeds.feedburner.com/~s/AtomicPlayboy?i=http://atomicplayboy.net/blog/2003/02/05/like-switch/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://atomicplayboy.net/blog/2003/02/05/like-switch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
