<?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>WP Garage &#187; parent</title>
	<atom:link href="http://wpgarage.com/tag/parent/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpgarage.com</link>
	<description>wordpress tricks, hacks, and tips</description>
	<lastBuildDate>Tue, 15 May 2012 11:49:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How to create a Simple Directory in WordPress using Grandparent, Parent, and Child Pages</title>
		<link>http://wpgarage.com/code-snippets/how-to-create-a-simple-directory-in-wordpress-using-grandparent-parent-and-child-pages/</link>
		<comments>http://wpgarage.com/code-snippets/how-to-create-a-simple-directory-in-wordpress-using-grandparent-parent-and-child-pages/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 10:04:13 +0000</pubDate>
		<dc:creator>Rebecca Markowitz</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[child]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[grandparent]]></category>
		<category><![CDATA[Pages]]></category>
		<category><![CDATA[parent]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://wordpressgarage.com/?p=464</guid>
		<description><![CDATA[<p>I wanted to create a simple directory of non-profit organizations. To do so,  I wanted to use pages for the directory, rather than posts so that I could separate the static directory listings from the dynamic blog posts. I didn&#8217;t want to have to exclude tons of categories from feedburner and the main loop. So, [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-create-a-simple-directory-in-wordpress-using-grandparent-parent-and-child-pages/">How to create a Simple Directory in WordPress using Grandparent, Parent, and Child Pages</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/how-to-create-a-simple-directory-in-wordpress-using-grandparent-parent-and-child-pages/" data-url="http://illum.in/nehRIx" data-text="How to create a Simple Directory in WordPress using Grandparent, Parent, and Child Pages" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/how-to-create-a-simple-directory-in-wordpress-using-grandparent-parent-and-child-pages/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/how-to-create-a-simple-directory-in-wordpress-using-grandparent-parent-and-child-pages/"></g:plusone></div></div><p>I wanted to create a simple directory of non-profit organizations. To do so,   I wanted to use pages for the directory, rather than posts so that I could separate the static directory listings from the dynamic blog posts. I didn&#8217;t want to have to exclude tons of categories from feedburner and the main loop.</p>
<p>So, I started exploring the whole family in WordPress &#8211; grandparents, parents, and children. Translation for those not yet used to seeing WordPress analagous to the family in My Big Fat Greek Wedding: Pages, sub-pages, and sub-sub pages</p>
<p><strong>Simple Directory Setup<br />
</strong></p>
<ul>
<li>Directory Page (grandparent): Displays list of Non-Profit Organization Categories  (ex. social, environment, health, etc.)</li>
<li>Category Page (parent): Show title and excerpt of each Organization within a category (ex. Environment Organizations)</li>
<li>Single Organization Page (child/current): Show content about a single organization(ex.  SaveTheEarth &#8211; made up org for this example)</li>
</ul>
<p><strong>Here&#8217;s how to do it</strong></p>
<ol>
<li>Create a Page Called Directory. This will be the <strong>Directory Page</strong> (grandparent)</li>
<li>Find the Page ID. Let&#8217;s say the Page ID = 5. Depending on how you want to display the category info, you can</li>
<li> Manually add the name of each category, a short description and a link</li>
<li>Open up page.php so we can setup <strong>The Category Page</strong> (Parent Page). We want to show title and excerpts of each organization for each category.</li>
<li>Add this code to page.php &#8211; Checks if we&#8217;re on a sub page / child page of the Directory (Page ID =10) and if so, list the pages in alphabetical order with excerpts. For the excerpt, I&#8217;m using the plugin Limit Posts since it didn&#8217;t work with The Excerpt Reloaded.&lt;?php<br />
$current = $post-&gt;ID;<br />
$parent = $post-&gt;post_parent;<br />
$grandparent_get = get_post($parent);<br />
$grandparent = $grandparent_get-&gt;post_parent;<br />
?&gt;</p>
<p>&lt;?php if ( $post-&gt;post_parent==&#8221;10&#8243;   ){ ?&gt;<br />
&lt;?php $pageChildren = $wpdb-&gt;get_results(&#8220;SELECT *    FROM $wpdb-&gt;posts WHERE post_parent = &#8220;.$post-&gt;ID.&#8221;    AND post_type = &#8216;page&#8217; ORDER BY post_title ASC&#8221;, &#8216;OBJECT&#8217;);    ?&gt;</p>
<p>&lt;h2 class=&#8221;titles&#8221;&gt;&lt;a href=&#8221;&lt;? php echo get_permalink($pageChild-&gt;ID);  ?&gt;&#8221;&gt; &lt;? php echo $pageChild-&gt;post_title;  ?&gt;&lt;/a&gt;&lt;/h2&gt;</p>
<p>&lt;?php the_content_limit(280, &#8220;&#8221;); ?&gt;&lt;div class=&#8221;readmore&#8221;&gt;&lt;a href=&#8221;&lt;?php echo get_permalink($pageChild-&gt;ID); ?&gt;&#8221; rel=&#8221;bookmark&#8221; title=&#8221;Permanent Link to &lt;? php echo $pageChild-&gt;post_title;   ?&gt;&#8221;&gt;Read More &amp;raquo;&lt;/a&gt;&lt;/div&gt;</p>
<p>(make sure to delete the space between &lt;? and php -  I had to to do that so it wouldn&#8217;t execute in this post)</li>
<li><strong>Single Organization Page </strong>(Child Page) On page.php, after the code you added in step 5, add this code that will check to see if we&#8217;re on the grandchild page. This will be the actual organization&#8217;s page. In our example, the SaveTheEarth Page. This is very helpful information in case you want to add a different style or add special items in the sidebar, etc.<br />
&lt;?php if ( $pageChildren ) : foreach ( $pageChildren as $pageChild ) : setup_postdata( $pageChild ); ?&gt;</li>
</ol>
<p style="padding-left: 30px;">7. Set up how the rest of the pages on your site will look:</p>
<p style="padding-left: 30px;">On page.php, after the code in step 6, add this code which instructs every other page in the site to act normally and display the content</p>
<p style="padding-left: 30px;">&lt;?php endforeach; ?&gt;<br />
&lt;?php else : ?&gt;</p>
<p style="padding-left: 30px;">&lt;?php the_content(); ?&gt;<br />
&lt;?php  endif; ?&gt;</p>
<p style="padding-left: 30px;">
<p><strong>You can see the full page.php code <a href="wp-content/uploads/2009/06/page.txt">here</a></strong></p>
<p><strong>You can see the directory in action <a href="http://israelnonprofitnews.com/directory/">here</a><br />
</strong></p>
<p>I figured this out using the following helpful posts:</p>
<p>*<a href="http://wordpress.org/support/topic/186206"> http://wordpress.org/support/topic/186206</a><br />
* <a href="http://wpguru.co.za/page/display-title-excerpt-of-child-page">http://wpguru.co.za/page/display-title-excerpt-of-child-page</a></p>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-create-a-simple-directory-in-wordpress-using-grandparent-parent-and-child-pages/">How to create a Simple Directory in WordPress using Grandparent, Parent, and Child Pages</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/how-to-create-a-simple-directory-in-wordpress-using-grandparent-parent-and-child-pages/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>

