<?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>Alessandro Melandri &#187; WordPress</title>
	<atom:link href="http://www.melandri.net/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.melandri.net</link>
	<description>J2EE Developer &#38; Photography enthusiast</description>
	<lastBuildDate>Tue, 27 Jul 2010 19:00:00 +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>WordPress queries</title>
		<link>http://www.melandri.net/2010/03/09/wordpress-queries/</link>
		<comments>http://www.melandri.net/2010/03/09/wordpress-queries/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 10:50:26 +0000</pubDate>
		<dc:creator>amelandri</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.melandri.net/?p=904</guid>
		<description><![CDATA[WordPress tip: Get rid of unused post revisions 10+ life saving SQL queries Some useful WordPress database queries]]></description>
			<content:encoded><![CDATA[<blockquote><p>
<a href="http://www.wprecipes.com/wordpress-tip-get-rid-of-unused-post-revisions" target="_blank">WordPress tip: Get rid of unused post revisions</a><br />
<a href="http://www.catswhocode.com/blog/wordpress-10-life-saving-sql-queries" target="_blank">10+ life saving SQL queries</a>
</p></blockquote>
<p>Some useful WordPress database queries</p>
]]></content:encoded>
			<wfw:commentRss>http://www.melandri.net/2010/03/09/wordpress-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selective Javascript Loader 1.1</title>
		<link>http://www.melandri.net/2009/09/14/selective-javascript-loader-1-1/</link>
		<comments>http://www.melandri.net/2009/09/14/selective-javascript-loader-1-1/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 09:11:46 +0000</pubDate>
		<dc:creator>amelandri</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[Selective]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.melandri.net/?p=582</guid>
		<description><![CDATA[I&#8217;ve just update the Selective Javascript Loader plugin with some bugfixes and improvements: Added the option to choose if Javascript files should be included in the header or in the footer of the page. This option is available only if you are using WordPress 2.8 and above Added WordPress version checking. Corrected script inclusion for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just update the <a href="http://www.melandri.net/projects/selective-javascript-loader/">Selective Javascript Loader</a> plugin with some bugfixes and improvements:</p>
<ul>
<li>Added the option to choose if Javascript files should be included in the header or in the footer of the page. This option is available only if you are using WordPress 2.8 and above</li>
<li>Added WordPress version checking.</li>
<li>Corrected script inclusion for WordPress 2.7</li>
<li>Some code optimization</li>
<li>Corrected a layout bug in the settings page</li>
</ul>
<p><a href="http://www.melandri.net/projects/selective-javascript-loader/">Read more</a> or <a href="http://wordpress.org/extend/plugins/selective-javascript-loader"><strong>download it</strong></a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.melandri.net/2009/09/14/selective-javascript-loader-1-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Selective Javascript Loader</title>
		<link>http://www.melandri.net/2009/09/13/selective-javascript-loader/</link>
		<comments>http://www.melandri.net/2009/09/13/selective-javascript-loader/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 17:16:49 +0000</pubDate>
		<dc:creator>amelandri</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[Selective]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.melandri.net/?p=566</guid>
		<description><![CDATA[I&#8217;ve just released Selective Javascript Loader my first WordPress plugin. It&#8217;s a very simple plugin that automatically loads different Javascript files based on the blog section that is being viewed (index, category, single post, page). It can be really useful if you make extensive use of Javascript in your theme and want to split the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released <strong><a href="http://www.melandri.net/projects/selective-javascript-loader">Selective Javascript Loader</a></strong> my first <a href="http://wordpress.org">WordPress</a> plugin. It&#8217;s a very simple plugin that automatically loads different Javascript files based on the blog section that is being viewed (index, category, single post, page).</p>
<p>It can be really useful if you make extensive use of Javascript in your theme and want to split the code and load functions only when you need them.</p>
<p><a href="http://www.melandri.net/projects/selective-javascript-loader"><strong>Check it out</strong></a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.melandri.net/2009/09/13/selective-javascript-loader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Today links</title>
		<link>http://www.melandri.net/2009/08/19/today-links-3/</link>
		<comments>http://www.melandri.net/2009/08/19/today-links-3/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 19:38:57 +0000</pubDate>
		<dc:creator>amelandri</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.melandri.net/?p=469</guid>
		<description><![CDATA[10 Handy WordPress Comments Hacks Power Tips For WordPress Template Developers 10 Useful WordPress Hook Hacks]]></description>
			<content:encoded><![CDATA[<ul>
<li><a href="http://www.smashingmagazine.com/2009/07/23/10-wordpress-comments-hacks/">10 Handy WordPress Comments Hacks</a></li>
<li><a href="http://www.smashingmagazine.com/2009/07/02/power-tips-for-wordpress-template-developers/">Power Tips For WordPress Template Developers</a></li>
<li><a href="http://www.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/">10 Useful WordPress Hook Hacks</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.melandri.net/2009/08/19/today-links-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress: single post template based on category #2</title>
		<link>http://www.melandri.net/2009/08/09/wordpress-single-post-template-based-on-category-2/</link>
		<comments>http://www.melandri.net/2009/08/09/wordpress-single-post-template-based-on-category-2/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 09:37:37 +0000</pubDate>
		<dc:creator>amelandri</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.melandri.net/?p=289</guid>
		<description><![CDATA[In my previous post I talked about a Lorelle blog post on creating single post templates for different categories. After using the code snippets &#8220;has is&#8221; I tryed to build a more flexible solution so I&#8217;ve come up with this little function: function getSingleTemplate&#40;&#41;&#123; &#160; $category = get_the_category&#40;&#41;; $templateName = TEMPLATEPATH . '/single_' . $category&#91;0&#93;-&#62;category_nicename [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://www.melandri.net/2009/08/07/wordpress-single-post-template-based-on-category/">previous post</a> I talked about a <a href="http://lorelle.wordpress.com/">Lorelle</a> blog <a href="http://lorelle.wordpress.com/2005/09/22/creating-multiple-single-posts-for-different-categories/">post</a> on creating single post templates for different categories.</p>
<p>After using the code snippets &#8220;has is&#8221; I tryed to build a more flexible solution so I&#8217;ve come up with this little function:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> getSingleTemplate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000088;">$category</span> <span style="color: #339933;">=</span> get_the_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$templateName</span> <span style="color: #339933;">=</span> TEMPLATEPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/single_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$category</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">category_nicename</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'.php'</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$templateName</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$templateName</span> <span style="color: #339933;">=</span> TEMPLATEPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/single_default.php'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$templateName</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This function must be called inside the <em>single.php</em> template: it gets the first post&#8217;s category, searches for a template named like &#8220;single_<em>post_first_category_slug</em>.php&#8221; and returns its path; if the file doesn&#8217;t exists it will return the <em>single_default.php</em> template path.</p>
<p>My <em>single.php</em> template:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span> getSingleTemplate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.melandri.net/2009/08/09/wordpress-single-post-template-based-on-category-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress: single post template based on category</title>
		<link>http://www.melandri.net/2009/08/07/wordpress-single-post-template-based-on-category/</link>
		<comments>http://www.melandri.net/2009/08/07/wordpress-single-post-template-based-on-category/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 15:28:06 +0000</pubDate>
		<dc:creator>amelandri</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.melandri.net/?p=283</guid>
		<description><![CDATA[Today, while trying to customize the single.php template for a specific category I found a pretty old article written by Lorelle: Creating Multiple Single Posts for Different Categories. Her tip is really simple and really useful: just rename your single.php to single1.php and create a new single2.php with your category specific layout; after that, create [...]]]></description>
			<content:encoded><![CDATA[<p>Today, while trying to customize the <em>single.php</em> template for a specific category I found a pretty old article written by <a href="http://lorelle.wordpress.com">Lorelle</a>: </p>
<p><a href="http://lorelle.wordpress.com/2005/09/22/creating-multiple-single-posts-for-different-categories/"><strong>Creating Multiple Single Posts for Different Categories</strong></a>.</p>
<p>Her tip is really simple and really useful: just rename your <em>single.php</em> to <em>single1.php</em> and create a new <em>single2.php</em> with your category specific layout; after that, create a new <em>single.php</em> file with this code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> in_category<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span>TEMPLATEPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/single2.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span>TEMPLATEPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/single1.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>So, if the post is in category 1 WordPress will use the <em>single2.php</em> otherwise it will use <em>single1.php</em>.</p>
<h3>Updated</h3>
<p>I wrote a more flexible solution: <a href="http://www.melandri.net/2009/08/09/wordpress-single-post-template-based-on-category-2/">check it out</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.melandri.net/2009/08/07/wordpress-single-post-template-based-on-category/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add a category filter to WordPress search form</title>
		<link>http://www.melandri.net/2009/08/05/add-a-category-filter-to-wordpress-search-form/</link>
		<comments>http://www.melandri.net/2009/08/05/add-a-category-filter-to-wordpress-search-form/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 07:06:41 +0000</pubDate>
		<dc:creator>amelandri</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.melandri.net/?p=236</guid>
		<description><![CDATA[WordPress has a simple function to build a search form for your blog and in this tutorial I&#8217;ll show you how to add a category filter to it. &#60;?php get_search_form&#40;&#41;; ?&#62; This function will look for a file called searchform.php inside your template folder: if it doesn&#8217;t exist it will output the standard search form. [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress has a simple function to build a search form for your blog and in this tutorial I&#8217;ll show you how to add a category filter to it.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_search_form<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This function will look for a file called <em>searchform.php</em> inside your template folder: if it doesn&#8217;t exist it will output the standard search form. So, if it isn&#8217;t already in place, create your custom <em>searchform.php</em> and copy into it the default search form output. It should look similar to this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> role<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;search&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;get&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;searchform&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php bloginfo('siteurl'); ?&gt;</span></span>&quot;&gt;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen-reader-text&quot;</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;s&quot;</span>&gt;</span>Search for:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;searchsubmit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Search&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<p><span id="more-236"></span></p>
<p>We want to add a select box to let the user search in a specific category or in all categories: to achive this we&#8217;ll use another default WordPress function.</p>
<p>The <a href="http://codex.wordpress.org/Template_Tags/wp_dropdown_categories" title="wp_dropdown_categories documentation"><em>wp_dropdown_categories</em></a> function will build for you a select box with all your categories. Take a look at the <a href="http://codex.wordpress.org/Template_Tags/wp_dropdown_categories" title="wp_dropdown_categories documentation">documentation</a> for all available options.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;?php wp_dropdown_categories<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'show_option_all=All Categories'</span> <span style="color: #66cc66;">&#41;</span>; ?&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- This is a sample output of the function --&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'cat'</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'cat'</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'postform'</span> &gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'0'</span> <span style="color: #000066;">selected</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'selected'</span>&gt;</span>All Categories<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;level-0&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span>&gt;</span>Uncategorized<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;level-0&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3&quot;</span>&gt;</span>HTML <span style="color: #ddbb00;">&amp;amp;</span> CSS<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;level-0&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4&quot;</span>&gt;</span>Java<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;level-0&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5&quot;</span>&gt;</span>Links<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;level-0&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;6&quot;</span>&gt;</span>Linux<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;level-0&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;9&quot;</span>&gt;</span>Javascript<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;level-0&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;32&quot;</span>&gt;</span>XML<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span></pre></div></div>

<p>Now add the category select box to the form modifying your <em>searchform.php</em> like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> role<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;search&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;get&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;searchform&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php bloginfo('siteurl'); ?&gt;</span></span>&quot;&gt;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen-reader-text&quot;</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;s&quot;</span>&gt;</span>Search for:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> 
    in <span style="color: #009900;">&lt;?php wp_dropdown_categories<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'show_option_all=All Categories'</span> <span style="color: #66cc66;">&#41;</span>; ?&gt;</span> 
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;searchsubmit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Search&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<p>That&#8217;s it. It just works out of the box.</p>
<h3>A finishing touch</h3>
<p>Now that you have a nice category filter in your search form it would be great to modify the search result page and add something like <em>Search result for &#8220;foo&#8221; in category &#8220;bar&#8221;</em>.<br />
Well, it&#8217;s quite easy: we need do add a simple function to the <a href="http://codex.wordpress.org/Theme_Development#Theme_Functions_File" title="About function.php"><em>function.php</em></a> file. Remember that every function in this file will be automatically available in your theme.</p>
<p>This is a simple function that gets the <em>cat</em> parameter from the request and if it&#8217;s not null it searches the category name. It has two input parameters so you can pass two strings to be displayed before and after the category name. If <em>cat</em> is null or empty or &#8220;0&#8243; (All categories) it will return an empty string.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> getCatSearchFilter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pre</span><span style="color: #339933;">,</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000088;">$category</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$catId</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;cat&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$catId</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$catId</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$catId</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$category</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pre</span><span style="color: #339933;">.</span>get_cat_name<span style="color: #009900;">&#40;</span><span style="color: #000088;">$catId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$category</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now open you search.php, add the function call to the page and you are done:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Search Results for <span style="color: #009900;">&lt;?php echo<span style="color: #66cc66;">&#40;</span>get_search_query<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;?&gt;&lt;?php echo<span style="color: #66cc66;">&#40;</span>getCatSearchFilter<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">' in category '</span>,<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;?&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.melandri.net/2009/08/05/add-a-category-filter-to-wordpress-search-form/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>WordPress Configuration Tricks</title>
		<link>http://www.melandri.net/2009/06/30/wordpress-configuration-tricks/</link>
		<comments>http://www.melandri.net/2009/06/30/wordpress-configuration-tricks/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 09:13:27 +0000</pubDate>
		<dc:creator>amelandri</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.melandri.net/?p=137</guid>
		<description><![CDATA[Take a look at this post for a list of useful &#8220;hidden&#8221; configuration settings for your WordPress installation. I found some nice tricks that I&#8217;ve applied to my wp-config.php: // Number of post revision to keep define&#40;'WP_POST_REVISIONS', 3&#41;; &#160; // Installation path and template path to reduce database queries define&#40;'WP_HOME', 'http://your_site_url.com'&#41;; define&#40;'WP_SITEURL', 'http://your_wordpress_directory_url.com'&#41;; &#160; define&#40;'TEMPLATEPATH', [...]]]></description>
			<content:encoded><![CDATA[<p>Take a look at <a href="http://diggingintowordpress.com/2009/06/wordpress-configuration-tricks/" target="_blank">this post</a> for a list of useful &#8220;hidden&#8221; configuration settings for your WordPress installation.<br />
I found some nice tricks that I&#8217;ve applied to my <code>wp-config.php</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Number of post revision to keep</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_POST_REVISIONS'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Installation path and template path to reduce database queries</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_HOME'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://your_site_url.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_SITEURL'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://your_wordpress_directory_url.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'TEMPLATEPATH'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/absolute/path/to/wp-content/themes/active-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'STYLESHEETPATH'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/absolute/path/to/wp-content/themes/active-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Security keys to improve cookies encription</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'AUTH_KEY'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'randomKey'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SECURE_AUTH_KEY'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'randomKey'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'LOGGED_IN_KEY'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'randomKey'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'NONCE_KEY'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'randomKey'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>via <a href="http://diggingintowordpress.com" target="_blank">Digging Into WordPress</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.melandri.net/2009/06/30/wordpress-configuration-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom taxonomies in WordPress 2.8</title>
		<link>http://www.melandri.net/2009/06/20/custom-taxonomies-in-wordpress-2-8/</link>
		<comments>http://www.melandri.net/2009/06/20/custom-taxonomies-in-wordpress-2-8/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 09:00:14 +0000</pubDate>
		<dc:creator>amelandri</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[taxonomy]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.melandri.net/?p=91</guid>
		<description><![CDATA[A really good tutorial on building custom taxonomies in WordPress 2.8. Custom taxonomies in WordPress 2.8]]></description>
			<content:encoded><![CDATA[<p>A really good tutorial on building custom taxonomies in WordPress 2.8.</p>
<p><a title="Justin Tadlock - Custom taxonomies in WordPress 2.8" href="http://justintadlock.com/archives/2009/05/06/custom-taxonomies-in-wordpress-28" target="_blank">Custom taxonomies in WordPress 2.8</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.melandri.net/2009/06/20/custom-taxonomies-in-wordpress-2-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress permalinks best practices</title>
		<link>http://www.melandri.net/2009/06/18/wordpress-permalinks-best-practices/</link>
		<comments>http://www.melandri.net/2009/06/18/wordpress-permalinks-best-practices/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 19:16:35 +0000</pubDate>
		<dc:creator>amelandri</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[permalinks]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.melandri.net/?p=88</guid>
		<description><![CDATA[Dougal Campbell wrote some interesting notes on permalinks structure and best practices in WordPress.  Worth reading: Efficient permalink strategies for WordPress – Dougal Campbell&#8217;s geek ramblings.]]></description>
			<content:encoded><![CDATA[<p><a title="Dougal Campbell blod" href="http://dougal.gunters.org/" target="_blank">Dougal Campbell</a> wrote some interesting notes on permalinks structure and best practices in WordPress.  Worth reading:</p>
<p><a href="http://dougal.gunters.org/blog/2009/02/04/efficient-wordpress-permalinks#more-1431">Efficient permalink strategies for WordPress – Dougal Campbell&#8217;s geek ramblings</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.melandri.net/2009/06/18/wordpress-permalinks-best-practices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
