<?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>WP Garage &#187; multiple</title>
	<atom:link href="http://wpgarage.com/tag/multiple/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpgarage.com</link>
	<description>wordpress tricks, hacks, and tips</description>
	<lastBuildDate>Tue, 15 May 2012 11:49:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How to Customize Multiple Search Result Pages in WordPress</title>
		<link>http://wpgarage.com/code-snippets/how-to-customize-multiple-search-result-pages-in-wordpress/</link>
		<comments>http://wpgarage.com/code-snippets/how-to-customize-multiple-search-result-pages-in-wordpress/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 07:26:02 +0000</pubDate>
		<dc:creator>Rebecca Markowitz</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[WordPress as CMS]]></category>
		<category><![CDATA[customize]]></category>
		<category><![CDATA[multiple]]></category>
		<category><![CDATA[Pages]]></category>
		<category><![CDATA[results]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://wordpressgarage.com/?p=498</guid>
		<description><![CDATA[<p>In the previous post, we discussed how to hack the search function in WordPress to have an additional search form that would search  subcategories. Now that you have 2 or more search forms on your site, you might need to customize the search results. Thanks to this solution, I learned how to create multiple search [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-customize-multiple-search-result-pages-in-wordpress/">How to Customize Multiple Search Result Pages in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/how-to-customize-multiple-search-result-pages-in-wordpress/" data-url="http://illum.in/ocOae3" data-text="How to Customize Multiple Search Result Pages in WordPress" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/how-to-customize-multiple-search-result-pages-in-wordpress/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/how-to-customize-multiple-search-result-pages-in-wordpress/"></g:plusone></div></div><p>In the previous post, we discussed how to <a href="code-snippets/how-to-hack-the-wordpress-search-function-search-categories-and-child-categories/">hack the search function</a> in WordPress to have an additional search form that would search  subcategories. Now that you have 2 or more search forms on your site, you might need to customize the search results. Thanks to <a href="http://www.rob-barrett.com/post/multiple-search-results-pages-within-one-wordpress-site">this solution</a>, I learned how to create multiple search result pages.</p>
<p>Let&#8217;s say we have 2 search forms on our site:</p>
<ol>
<li>General Site-Wide Search</li>
<li>Recipe Search &#8211; searches subcategories of the Recipe Category</li>
</ol>
<p>The first thing we need to do is tweak the search.php template to use it as a filter that will recognize if a search is coming from the Site-Wide search form or the Recipe Search form.</p>
<p><strong>1. Open Search.php</strong> and delete everything.  Add the following code:</p>
<blockquote><p>&lt;?php<br />
/* Template Name: Search Results */<br />
$search_refer = $_GET["site_section"];<br />
if ($search_refer == &#8216;recipe&#8217;) { load_template(TEMPLATEPATH . &#8216;/recipe-search.php&#8217;); }<br />
elseif ($search_refer == &#8216;site-search&#8217;) { load_template(TEMPLATEPATH . &#8216;/site-search.php&#8217;); }; ?&gt;</p></blockquote>
<p><strong>2. Open Header.php</strong> or wherever the General Site-Wide Search Form is located and add this line:</p>
<blockquote><p>&lt;input type=&#8221;hidden&#8221; name=&#8221;site_section&#8221; value=&#8221;site-search&#8221; /&gt;</p></blockquote>
<p><strong>The Site-Wide Search form will look something like this:</strong></p>
<blockquote><p>&lt;form method=&#8221;get&#8221; id=&#8221;searchform&#8221; action=&#8221;&lt;?php bloginfo(&#8216;home&#8217;); ?&gt;/&#8221;&gt;<br />
&lt;div id=&#8221;search&#8221;&gt;<br />
&lt;input type=&#8221;text&#8221; value=&#8221; &#8221; onclick=&#8221;this.value=&#8221;;&#8221; name=&#8221;s&#8221; id=&#8221;s&#8221; /&gt;<strong><br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;site_section&#8221; value=&#8221;site-search&#8221; /&gt;</strong><br />
&lt;input name=&#8221;" type=&#8221;image&#8221; src=&#8221;&lt;?php bloginfo(&#8216;stylesheet_directory&#8217;); ?&gt;/styles/&lt;?php echo &#8220;$style_path&#8221;; ?&gt;/search.gif&#8221; value=&#8221;Go&#8221; /&gt;<br />
&lt;/div&gt;&lt;!&#8211;/search &#8211;&gt;<br />
&lt;/form&gt;</p></blockquote>
<p><strong>3. </strong><strong>Open Recipes.php</strong> or wherever your second search is and insert this line:</p>
<blockquote><p><strong>&lt;input type=&#8221;hidden&#8221; name=&#8221;site_section&#8221; value=&#8221;recipe&#8221; /&gt; </strong></p></blockquote>
<p>You can change the value &#8220;recipe&#8221; to whatever suits your needs. Just make sure it matches the value in search.php.</p>
<p><strong>The Recipe Search form for your second search</strong> <strong>will look something like this</strong>. In my case, this second search is meant to search the subcategories of the Recipe category.  See my previous post to learn about<a href="code-snippets/how-to-hack-the-wordpress-search-function-search-categories-and-child-categories/"> hacking the search function to search subcategories.</a></p>
<blockquote><p>&lt;form method=&#8221;get&#8221; id=&#8221;rsearchform&#8221; action=&#8221;&lt;?php bloginfo(&#8216;home&#8217;); ?&gt;/&#8221;&gt;<br />
&lt;div id=&#8221;rsearch&#8221;&gt;<br />
&lt;input type=&#8221;text&#8221; value=&#8221;Recipe Search&#8230; &#8221; onclick=&#8221;this.value=&#8221;;&#8221; name=&#8221;s&#8221; id=&#8221;rs&#8221; /&gt;<br />
&lt;?php $categories = get_categories(&#8216;child_of=11&#8242;);<br />
$catlist = &#8221;;<br />
foreach ($categories as $cat) {<br />
$catlist.= $cat-&gt;cat_ID.&#8217;,';<br />
}<br />
$catlist.&#8217;11&#8242;;<br />
?&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;cat&#8221; value=&#8221;&lt;?php echo &#8220;$catlist&#8221;?&gt;&#8221; /&gt;<br />
<strong>&lt;input type=&#8221;hidden&#8221; name=&#8221;site_section&#8221; value=&#8221;recipe&#8221; /&gt; </strong><br />
&lt;input name=&#8221;" type=&#8221;image&#8221; src=&#8221;&lt;?php bloginfo(&#8216;stylesheet_directory&#8217;); ?&gt;/styles/&lt;?php echo &#8220;$style_path&#8221;; ?&gt;/search.gif&#8221; value=&#8221;Go&#8221; /&gt;<br />
&lt;/div&gt;&lt;!&#8211;/search &#8211;&gt;<br />
&lt;/form&gt;</p></blockquote>
<p><strong>4. Customize the Search Results Templates</strong></p>
<p>If you recall, in step 1, we added the following to the search.php page.</p>
<blockquote><p>if ($search_refer == &#8216;recipe&#8217;) { load_template(TEMPLATEPATH . &#8216;/recipe-search.php&#8217;); }<br />
elseif ($search_refer == &#8216;site-search&#8217;) { load_template(TEMPLATEPATH . &#8216;/site-search.php&#8217;); }; ?&gt;</p></blockquote>
<p>Create recipe-search.php (or whatever you named this template) and customize the layout of the results page to your liking. You can use index.php to start with and customize from there.</p>
<p>Create site-search.php (or whatever you named this template) and customize the layout of the results page to your liking. You can use index.php to start with and customize from there.</p>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-customize-multiple-search-result-pages-in-wordpress/">How to Customize Multiple Search Result Pages in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/how-to-customize-multiple-search-result-pages-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

