<?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>33dots &#187; page template</title>
	<atom:link href="http://www.33dots.com/index.php/tag/page-template/feed" rel="self" type="application/rss+xml" />
	<link>http://www.33dots.com</link>
	<description></description>
	<lastBuildDate>Wed, 12 Oct 2011 17:07:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Displaying posts in a category as a page in wordpress</title>
		<link>http://www.33dots.com/index.php/wordpress/displaying-posts-in-a-category-as-a-page-in-wordpress.html</link>
		<comments>http://www.33dots.com/index.php/wordpress/displaying-posts-in-a-category-as-a-page-in-wordpress.html#comments</comments>
		<pubDate>Thu, 06 Aug 2009 10:32:20 +0000</pubDate>
		<dc:creator>tony</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[category as page]]></category>
		<category><![CDATA[page template]]></category>

		<guid isPermaLink="false">http://www.33dots.com/?p=143</guid>
		<description><![CDATA[In this site the Life page only displays the posts in the category Life.
I did this in a manual way by creating a Page Template for the Life page. This gives you more control. The problem with this approach is that you have to do it again for a new theme.
In wordpress, individual pages can [...]]]></description>
			<content:encoded><![CDATA[<p>In this site the <a title="Life page" href="/index.php/life" target="_self">Life</a> page only displays the posts in the category <a title="Category page of Life" href="/index.php/category/life" target="_self">Life</a>.<br />
I did this in a manual way by creating a Page Template for the Life page. This gives you more control. The problem with this approach is that you have to do it again for a new theme.</p>
<p>In wordpress, individual pages can be set to use a specific custom Page Template (a PHP template file, e.g., <em>life.php</em>) that we create within our Theme. The custom Page Template can be assigned while creating a new page. This new Page Template will then override the default <em>page.php</em> Page Template in the Theme.<br />
When loading a page, wordpress looks first for the assigned Page template, then the <em>page.php</em> and finally the <em>index.php</em>. The first one it finds will be used to display that Page. The template pages are situated in the theme&#8217;s directory which is at <em>wp-content/themes/your-theme</em></p>
<p>In our case we need a Page Template that will be similar to the home page but displays only the posts in the required category.<br />
So we will base our custom Page Template on index.php which is the Page Template of the home page.</p>
<p>We make a copy of  the <em>index.php</em> with the name <em>mypage.php</em> (or <em>anything.php</em>)</p>
<p>Add the following code to the top of it so that wordpress understands that it is a Page Template and identify its Template Name. This name will be displayed in the theme editor page.</p>
<pre>&lt;?php
/*
Template Name: MyPage
*/
?&gt;</pre>
<p>Now, we add the filter to display only the required category. This should be added just after the above Template Name code</p>
<pre>&lt;?php
if (is_home()) {
query_posts($query_string."&amp;cat=3");
}
?&gt;</pre>
<p>In this code we display only category with id 3. The <em>category id</em> can be found out from the wordpress <em>Edit Category</em> pages by mouse hovering the required category and its id will be shown in the browser&#8217;s status bar.<br />
Now to display more than one category use some thing like this<br />
<code>query_posts($query_string."&amp;cat=2,6,17,38");</code></p>
<p>Create a blank page and assign this custom template to it. [Look for a drop-down labeled "<em>Page Template</em>" towards the bottom]</p>
<p>Thats all!</p>
<p>For more detailed information on Page Templates, visit this <a title="Page Templates in wordpress codex site" href="http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates" target="_self">wordpress codex page</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.33dots.com/index.php/wordpress/displaying-posts-in-a-category-as-a-page-in-wordpress.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

