<?xml version="1.0" encoding="utf-8"?>
<!-- generator="wordpress/2.0.2" -->
<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/"
	>

<channel>
	<title>stewart ugelow</title>
	<link>http://www.ugelow.com/tags/permalinks/feed</link>
	<description>www.ugelow.com</description>
	<pubDate>Wed, 19 Apr 2006 23:38:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>
	<language>en</language>
			<item>
		<title>Simpler WordPress Search URLs</title>
		<link>http://www.ugelow.com/2006/04/19/simpler-wordpress-search-urls/</link>
		<pubDate>Wed, 19 Apr 2006 23:38:25 +0000</pubDate>
		
	<dc:subject>Dev</dc:subject>
	<dc:subject>WordPress</dc:subject><dc:subject>Cruft</dc:subject><dc:subject>Cruft Free</dc:subject><dc:subject>Permalinks</dc:subject><dc:subject>Wordpress</dc:subject>
		<guid isPermaLink="false">http://www.ugelow.com/2006/04/19/simpler-wordpress-search-urls/</guid>
		<description><![CDATA[WordPress-powered URLs ending in <span class="code">/search/foo</span> (where "foo" is your search term) now work the same way as the old-school format of <span class="code">index.php?s=foo</span>. They're cleaner, more intuitive, and darned easier on the eyes.

The only problem? The search form included in most templates produces old-school URLs instead of the newer ones. Thankfully, there's a simple, elegant workaround using the WordPress WP_Query class.]]></description>
			<content:encoded><![CDATA[<p>Thanks to some under-the-hood black magic, newer versions of WordPress support a streamlined permalink structure for search URLs. (In some corners, these are known as <a href="http://en.wikipedia.org/wiki/Cruft" target="_blank">&#8220;cruft-free&#8221; URLs.</a>) </p>
<p>WordPress-powered URLs ending in <span class="code">/search/foo</span> (where &#8220;<a href="http://en.wikipedia.org/wiki/Metasyntactic_variable#Foo.2C_Bar.2C_and_Baz" target="_blank">foo</a>&#8221; is your search term) now work the same way as the old-school format of <span class="code">index.php?s=foo</span>. They&#8217;re cleaner, more intuitive, and darned easier on the eyes.</p>
<p>The only problem? The search form included in most templates produces old-school URLs instead of the newer ones, and the various ways of recoding the search form (see last year&#8217;s <a href="http://comox.textdrive.com/pipermail/wp-hackers/2005-April/000719.html" target="_blank">discussion</a> on the wp-hackers mailing list) seem more trouble than they&#8217;re worth.</p>
<p>Thankfully, there&#8217;s a simple, elegant workaround using the WordPress <a href="http://codex.wordpress.org/Function_Reference/WP_Query" target="_blank">WP_Query</a> class. Just add the code below to the <em>very top</em> of your <code>header.php</code> template and say goodbye to ugly search URLs.</p>
<pre><code>&lt;?php
if ((is_search()) &amp;&amp; ($_GET['s'])) {
	wp_redirect(get_bloginfo('url')."/search/".get_query_var('s'));
} //if
?&gt;</code></pre>
<p>As usual, standard disclaimers apply.
</p>
]]></content:encoded>
			</item>
	</channel>
</rss>

