<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: WordPress query posts with tags not working!</title>
	<atom:link href="http://corpocrat.com/2010/07/20/wordpress-query-posts-with-tags-not-working/feed/" rel="self" type="application/rss+xml" />
	<link>http://corpocrat.com/2010/07/20/wordpress-query-posts-with-tags-not-working/</link>
	<description>Daily Blog from Internet Entrepreneur/Webmaster</description>
	<lastBuildDate>Tue, 07 Feb 2012 20:25:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Mark</title>
		<link>http://corpocrat.com/2010/07/20/wordpress-query-posts-with-tags-not-working/#comment-15240</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Tue, 07 Dec 2010 12:51:46 +0000</pubDate>
		<guid isPermaLink="false">http://corpocrat.com/?p=1209#comment-15240</guid>
		<description>I&#039;m no expert on WP but I can see that code snippet is bad for a number of reasons - assigning to the loop variable $tag (?), not comma (or +) separating the list you are trying to build, and not using the slug (name can contain spaces which won&#039;t work).

There&#039;s maybe a better way of doing this, but you can do:

$tagList = &#039;&#039;;
$tags =  get_the_tags();  

 if ($tags) {
	 foreach($tags as $tag) {
		$tagList = $tag-&gt;slug . &#039;,&#039;;
	 }
 }
 
$tagList = trim($tagList, &quot;,&quot;);
		
query_posts(&quot;tag=&quot; . $tagList);</description>
		<content:encoded><![CDATA[<p>I&#8217;m no expert on WP but I can see that code snippet is bad for a number of reasons &#8211; assigning to the loop variable $tag (?), not comma (or +) separating the list you are trying to build, and not using the slug (name can contain spaces which won&#8217;t work).</p>
<p>There&#8217;s maybe a better way of doing this, but you can do:</p>
<p>$tagList = &#8221;;<br />
$tags =  get_the_tags();  </p>
<p> if ($tags) {<br />
	 foreach($tags as $tag) {<br />
		$tagList = $tag-&gt;slug . &#8216;,&#8217;;<br />
	 }<br />
 }</p>
<p>$tagList = trim($tagList, &#8220;,&#8221;);</p>
<p>query_posts(&#8220;tag=&#8221; . $tagList);</p>
]]></content:encoded>
	</item>
</channel>
</rss>

