<?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>36Flavours.com &#187; categories</title>
	<atom:link href="http://36flavours.com/tag/categories/feed/" rel="self" type="application/rss+xml" />
	<link>http://36flavours.com</link>
	<description>A taste of something different...</description>
	<lastBuildDate>Mon, 09 Aug 2010 18:20:11 +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 exclude categories from homepage</title>
		<link>http://36flavours.com/2010/01/wordpress-exclude-categories-from-homepage/</link>
		<comments>http://36flavours.com/2010/01/wordpress-exclude-categories-from-homepage/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 19:42:08 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[exclude]]></category>
		<category><![CDATA[posts]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=592</guid>
		<description><![CDATA[If you use posts within WordPress to generate content, such as Frequently Asked Questions or Help Guides, it&#8217;s quite often the case that you don&#8217;t want these to appear on the posts page of your blog. Instead of having to re-create the whole query, you can append a comma separated list of category ID&#8217;s  that [...]]]></description>
			<content:encoded><![CDATA[<p class="first">If you use posts within <a href="http://wordpress.org/" target="_blank">WordPress</a> to generate content, such as <em>Frequently Asked Questions</em> or <em>Help Guides</em>, it&#8217;s quite often the case that you don&#8217;t want these to appear on the posts page of your blog.</p>
<p>Instead of having to re-create the whole query, you can append a <strong>comma separated list</strong> of category ID&#8217;s  that you want to exclude to the end of the original query and fetch the new data set to be used.<span id="more-592"></span></p>
<p>To achieve this, insert a variation of the following into your index or template file specified as the <strong>posts page</strong>:</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> query_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query_string</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;cat=-2,-3'</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 should be placed <strong>before</strong> the loop, therefore ideally just before:</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<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>

<p>Adding this line of code will check if the current page is the posts page (<a href="http://codex.wordpress.org/Conditional_Tags#The_Main_Page" target="_blank">is_home</a>) and if so <strong>exclude</strong> the categories with ID&#8217;s 2 and 3. Note here the <strong>negation</strong> used (-2 and -3), without this the query will include rather than exclude the categories.</p>
<p>If you don&#8217;t want to hard code ID values, you could use the <a href="http://codex.wordpress.org/Function_Reference/get_category_by_slug" target="_blank">get_category_by_slug</a> or <a href="http://codex.wordpress.org/Function_Reference/get_category_by_path" target="_blank">get_category_by_path</a> functions to fetch the category ID.</p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2010/01/wordpress-exclude-categories-from-homepage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
