<?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>Tom Greenaway &#187; wordpress</title>
	<atom:link href="http://www.tomgreenaway.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tomgreenaway.com</link>
	<description></description>
	<lastBuildDate>Fri, 11 Feb 2011 09:16:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>WordPress: Query Posts</title>
		<link>http://www.tomgreenaway.com/2009/02/wordpress-query-posts/</link>
		<comments>http://www.tomgreenaway.com/2009/02/wordpress-query-posts/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 04:07:43 +0000</pubDate>
		<dc:creator>TCMG</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://tgreenaway.com/?p=238</guid>
		<description><![CDATA[When you are interacting with WordPress&#8217;s Query Posts function the codex page gives great examples. However, the one glaring omission is documentation on how to handle variables with spaces. For example you might want to query for posts with the &#8230; <a href="http://www.tomgreenaway.com/2009/02/wordpress-query-posts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When you are interacting with WordPress&#8217;s Query Posts function the <a href="http://codex.wordpress.org/Template_Tags/query_posts">codex page gives great examples</a>.</p>
<p>However, the one glaring omission is documentation on how to handle variables with spaces. For example you might want to query for posts with the tag &#8220;Converse&#8221;, this is easily achievable with:</p>
<pre>
<pre class="brush: php;">

# the query terms are not case sensitive, so converse==ConVERsE==Converse

query_posts('showposts=1&amp;amp;amp;tag=converse');
</pre>
</pre>
<p>But what if you wanted to query for a tag that contained spaces in it, like &#8220;Onitsuka Tiger&#8221;? Unfortunately none of the examples on the WordPress page currently provide an answer and giving the query_posts function spaces doesn&#8217;t result in anything. And while you might assume urlencode or rawurlencode might be the answer &#8211; they&#8217;re not.</p>
<p>The answer is that the spaces must be replaced with hyphens:</p>
<pre>
<pre class="brush: php;">

$manufacturer_tag=str_replace(' ', '-', $manufacturer_name);

query_posts('showposts=1&amp;amp;amp;tag=' . $manufacturer_tag);
</pre>
</pre>
<p>Apart from that omission the WordPress codex is still undeniably one of the greatest examples of an OSource API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomgreenaway.com/2009/02/wordpress-query-posts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

