<?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>archGFX &#187; search</title>
	<atom:link href="http://archgfx.net/tag/search/feed" rel="self" type="application/rss+xml" />
	<link>http://archgfx.net</link>
	<description>Austin web designer - Adam Freetly</description>
	<lastBuildDate>Wed, 28 Sep 2011 13:50:27 +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>Adding Search results to WordPress 404 pages</title>
		<link>http://archgfx.net/blog/2007/geek/blogging/adding-search-results-to-wordpress-404-pages</link>
		<comments>http://archgfx.net/blog/2007/geek/blogging/adding-search-results-to-wordpress-404-pages#comments</comments>
		<pubDate>Wed, 12 Sep 2007 16:56:26 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[blogging]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[query_posts]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://archgfx.net/blog/2007/geek/blogging/adding-search-results-to-wordpress-404-pages</guid>
		<description><![CDATA[Okay, so all this redirection business, and the 404 logs it generates, made me really get annoyed with seeing the blank 404 page I have. It's just the basic page that comes with Sandbox. Looking at the page was especially frustrating, since I knew that the URL I was looking at was close to the [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so all this redirection business, and the 404 logs it generates, made me really get annoyed with seeing the blank 404 page I have.  It's just the basic page that comes with <a href="http://sndbx.org">Sandbox</a>.  Looking at the page was especially frustrating, since I knew that the <acronym title='Uniform Resource Locator'><span class='caps'>URL</span></acronym> I was looking at was close to the name of the page I was looking for.  Inspired by <a href="http://www.smashingmagazine.com/2007/07/25/wanted-your-404-error-pages/">Smashing Magazine's 404 usability post</a>, I set off to figure it out.</p>
<p>I started with the <a href="http://weblogtoolscollection.com/archives/2004/08/05/404-search-function-for-wordpress/">404 Search from Weblog Tools Collection</a>, which simply redirects 404 pages to search results.  That's not technically correct behaviour, so I borrowed the first few lines of my <code>404.php</code> from their example:</p>
<p><code>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$search_term = substr($_SERVER['REQUEST_URI'],1);
$search_term = urldecode(stripslashes($search_term));
$find = array (&quot;'.html'&quot;, &quot;'.+/'&quot;, &quot;'[-/_]'&quot;) ;
$replace = &quot; &quot; ;
$search_term = trim(preg_replace ( $find , $replace , $search_term ));
$search_term_q = preg_replace('/ /', '%20', $search_term);
get_header() ?&gt;
</pre>
<p></code></p>
<p>Then the rest of the 404 template, which you can  <a href="http://archgfx.net/blog/index.php/2006/history/1011001">check out here</a>, follows normally from <a href="http://sandbox-theme.googlecode.com/svn/trunk/404.php">the sandbox file</a>, until after the search field (which is important for usability).   I don't use this in my index or single page templates, because <a href="http://wpbits.wordpress.com/2007/08/21/making-wordpress-themes-ii-the-loop/#comment-618">404's shouldn't land there</a> (if they do, it's a problem with wp_query() ).  After the search field, we jump into a custom loop:</p>
<p><span id="more-1200"></span></p>
<p><code>
<pre class="brush: php; title: ; notranslate">
&lt;?php /* run the url as a query */
query_posts('s='. $search_term_q );
?&gt;
&lt;?php if ( have_posts() ) :
/* check to see if there are posts, before telling people something that isn't true */ ?&gt;
&lt;div class=&quot;content-column left&quot;&gt;&lt;h3&gt;You might have been looking for these posts&lt;/h3&gt;
&lt;ul&gt;
&lt;?php /* start the loop */
while ( have_posts() ) : the_post(); ?&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; title=&quot;&lt;?php printf(__('Permalink to %s', 'sandbox'), wp_specialchars(get_the_title(), 1)) ?&gt;&quot; rel=&quot;bookmark&quot;&gt;&lt;?php the_title() ?&gt;&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;abbr title=&quot;&lt;?php the_time('Y-m-d\TH:i:sO'); ?&gt;&quot;&gt;&lt;?php unset($previousday); printf(__('%1$s', 'sandbox'), the_date('', '', '', false), get_the_time()) ?&gt;&lt;/abbr&gt;&lt;br /&gt;
&lt;em&gt;
&lt;?php printf(__('Posted in %s', 'sandbox'), get_the_category_list(', ')) ?&gt;
. &amp;nbsp;
&lt;?php comments_popup_link(__('Comments (0)', 'sandbox'), __('Comments (1)', 'sandbox'), __('Comments (%)', 'sandbox')) ?&gt;
&lt;/em&gt;
&lt;/li&gt;
&lt;?php /* end the loop */
endwhile; ?&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;?php /* close the list before closing the ifelse */
else : endif; ?&gt;
</pre>
<p></code></p>
<p>You can read the comments, but basically, we take the <acronym title='Uniform Resource Locator'><span class='caps'>URL</span></acronym> and use <code>query_posts() </code>to run it as a search, and return the results as a list, if there are any.  So far, it works for posts that I've referenced elsewhere, but it's not returning the actual post itself.  That's probably because I use category slugs in my <acronym title='Uniform Resource Locator'><span class='caps'>URL</span></acronym>'s. and BTW, the fancy code highlighting in this post is courtesy of a <a href="http://wordpress.org/extend/plugins/syntaxhighlighter/">fancy new plugin</a>.</p>
<p><ins datetime="2007-09-12T22:36:46+00:00"><strong>UPDATE</strong>: Some additional code was used from <a href="http://www.arunrocks.com/blog/archives/2006/03/01/a-nearly-perfect-404-error-page-in-wordpress/">Arun's nearly perfect 404</a>.</ins></p>
]]></content:encoded>
			<wfw:commentRss>http://archgfx.net/blog/2007/geek/blogging/adding-search-results-to-wordpress-404-pages/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>result!</title>
		<link>http://archgfx.net/blog/2007/asides/result</link>
		<comments>http://archgfx.net/blog/2007/asides/result#comments</comments>
		<pubDate>Wed, 21 Feb 2007 18:37:52 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[free beer fundamentalists]]></category>
		<category><![CDATA[meme]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://archgfx.net/blog/2007/asides/result</guid>
		<description><![CDATA[lorelle's latest challenge precludes you from using your own name, but not the names of your posts. that would be too easy, though, so i dug in my stats a bit, and suddenly wondered why one of my custom CSS templates was so much more popular than the others: oh, that's because people are googling [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://lorelle.wordpress.com/2007/02/21/blog-challenge-what-keywords-make-you-number-one-in-google/">lorelle's latest challenge</a> precludes you from using your own name, but not the names of your posts.  that would be too easy, though, so i dug in my stats a bit, and suddenly wondered why <a href="http://sunburntkamel.archgfx.net/2007/01/17/fork-for-wordpresscom/">one of my custom <acronym title='Cascading Style Sheets'><span class='caps'>CSS</span></acronym> templates</a> was so much more popular than the others:  oh, that's because people are <a href="http://www.google.com/search?q=wordpress+fork">googling for a wordpress fork</a>.  if ever there was a metric for dissatisfaction with the hierarchy of your project, surely this is it.</p>
]]></content:encoded>
			<wfw:commentRss>http://archgfx.net/blog/2007/asides/result/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Searching for comments</title>
		<link>http://archgfx.net/blog/2006/asides/searching-for-comments</link>
		<comments>http://archgfx.net/blog/2006/asides/searching-for-comments#comments</comments>
		<pubDate>Sun, 06 Aug 2006 16:25:01 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://archgfx.net/blog/2006/asides/searching-for-comments</guid>
		<description><![CDATA[It's generally been agreed that the search built into wordpress doesn't work terribly well. mainly due to it's failure to index comments.  Being that i don't know javascript, i staunchly refuse to dump the livesearch into anything i do.  Well, that and the fact that it takes a good 10 seconds to run on any [...]]]></description>
			<content:encoded><![CDATA[<p>It's generally been agreed that the search built into wordpress doesn't work terribly well.  mainly due to it's failure to index comments.  Being that i don't know javascript, i staunchly refuse to dump the <a href="http://binarybonsai.com/archives/2004/09/25/livesearch/" title="live search">livesearch</a> into anything i do.  Well, that and the fact that it takes a good 10 seconds to run on any site that's not as optimized as wordpress.com.</p>
<p>Seeing the <a href="http://wordpress.org/search/" title="wordpress.org sitesearch, powered by yahoo!">search on wordpress.org</a>, i found an idea. <a href="http://developer.yahoo.com/download/" title="Yahoo web search SDK download">Yahoo!'s search <acronym title='Application Interface'><span class='caps'>API</span></acronym> is wide open</a>, and they have plenty of <a href="http://archgfx.net/phptest/example1/YahooSearchExample.php" title="Yahoo web search example">Example Code</a>.  (important for me, since i'm no expert)  it still needs a hell of a lot of tweaking, but it should be relatively easy to integrate into a theme, since theme authors can control what the results page looks like.</p>
<p>Unfortunately, this sort of thing <span>should</span> be implemented as a plugin.  which means going the route of <a href="http://www.randombyte.net/wiki/falbum/disconnected" title="falbum wiki on implementing the photo page">falbum</a>, or UTW, or whathaveyou, and distributing a basic template, and giving instructions on how to integrate it.</p>
]]></content:encoded>
			<wfw:commentRss>http://archgfx.net/blog/2006/asides/searching-for-comments/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

