<?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>Flav36rs &#187; categories</title>
	<atom:link href="http://flav36rs.com/tag/categories/feed/" rel="self" type="application/rss+xml" />
	<link>http://flav36rs.com</link>
	<description>Just another technical blog</description>
	<lastBuildDate>Mon, 12 Sep 2011 16:56:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>WordPress exclude categories from homepage</title>
		<link>http://flav36rs.com/2010/01/27/wordpress-exclude-categories-from-homepage/</link>
		<comments>http://flav36rs.com/2010/01/27/wordpress-exclude-categories-from-homepage/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 19:42:08 +0000</pubDate>
		<dc:creator>Steve</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 &#8230; <a href="http://flav36rs.com/2010/01/27/wordpress-exclude-categories-from-homepage/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>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>
<pre lang="php" escaped="true">&lt;?php if (is_home()) query_posts($query_string.'&amp;cat=-2,-3'); ?&gt;</pre>
<p>This should be placed <strong>before</strong> the loop, therefore ideally just before:</p>
<pre lang="php" escaped="true">&lt;?php if (have_posts()) : ?&gt;</pre>
<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://flav36rs.com/2010/01/27/wordpress-exclude-categories-from-homepage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

