<?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: Great Grand Parent ID&#8217;s in WordPress</title>
	<atom:link href="http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44%20%20/feed" rel="self" type="application/rss+xml" />
	<link>http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44</link>
	<description>Web Development Tutorials</description>
	<lastBuildDate>Sun, 23 May 2010 20:00:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: @shimapi</title>
		<link>http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44#comment-30</link>
		<dc:creator>@shimapi</dc:creator>
		<pubDate>Mon, 17 May 2010 16:56:15 +0000</pubDate>
		<guid isPermaLink="false">http://andyweigel.com/blog/?p=44#comment-30</guid>
		<description>Thanks a lot! this is really helpfull!!

:D</description>
		<content:encoded><![CDATA[<p>Thanks a lot! this is really helpfull!!</p>
<p> <img src='http://andyweigel.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: frank</title>
		<link>http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44#comment-27</link>
		<dc:creator>frank</dc:creator>
		<pubDate>Tue, 02 Mar 2010 18:44:58 +0000</pubDate>
		<guid isPermaLink="false">http://andyweigel.com/blog/?p=44#comment-27</guid>
		<description>I came up with a slight variation that outputs the parent or page &lt;b&gt;title&lt;/b&gt;. 

//get the root parent page title
function get_top_ancestor($id){
		$current = get_post($id);
		if(!$current-&gt;post_parent){
		return $current-&gt;post_title; &lt;!-- see the slight change --&gt;
		} else {
		return get_top_ancestor($current-&gt;post_parent);
		}
}

SO, if you put teh above script into your function.php and the following into your body tag like this:
&lt;body class=&quot;&quot;&gt;

Your CSS can control the following tag:
//the header background for about and it&#039;s children are now blue
.about .header{background-colour: blue;}
or change all the text links in the about section to orange(why… why not)
//all text on the about page and it&#039;s children are orange
.about a{color: orange;}

enjoy : )</description>
		<content:encoded><![CDATA[<p>I came up with a slight variation that outputs the parent or page <b>title</b>. </p>
<p>//get the root parent page title<br />
function get_top_ancestor($id){<br />
		$current = get_post($id);<br />
		if(!$current-&gt;post_parent){<br />
		return $current-&gt;post_title; <!-- see the slight change --><br />
		} else {<br />
		return get_top_ancestor($current-&gt;post_parent);<br />
		}<br />
}</p>
<p>SO, if you put teh above script into your function.php and the following into your body tag like this:<br />
&lt;body class=&quot;&#8221;&gt;</p>
<p>Your CSS can control the following tag:<br />
//the header background for about and it&#8217;s children are now blue<br />
.about .header{background-colour: blue;}<br />
or change all the text links in the about section to orange(why… why not)<br />
//all text on the about page and it&#8217;s children are orange<br />
.about a{color: orange;}</p>
<p>enjoy : )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: frank</title>
		<link>http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44#comment-26</link>
		<dc:creator>frank</dc:creator>
		<pubDate>Mon, 01 Mar 2010 18:10:25 +0000</pubDate>
		<guid isPermaLink="false">http://andyweigel.com/blog/?p=44#comment-26</guid>
		<description>Can I use the recursive script to get a page slug rather than the ID? This would be more useful when applying CSS. 

eg: Let&#039;s say I have two section on my site: About and Products.
About
--location
--number of staff
--hours

Products
--muffins
    --- blueberry
    --- bran
--belly button lint collector
--1.5&quot;floppy disks

I can add the following function to my function page:
ID, ARRAY_A);
$slug = $post_data[&#039;post_name&#039;];
return $slug; }
?&gt;


and this line to my header.php:
&lt;body class=&quot;&quot;&gt;

Now my page is wrapped in the slug name for the page. This is useful as a sort of &#039;if&quot; statement for CSS. 
// If this is about page: the header background is blue 
// If this is products page: the header background is red 

.about .header{background-colour: blue;}
.about .header{background-colour: red;}

This can be done with the ID as  you have it but it&#039;s not as easy to read:
.about .10{background-color: blue;}

The problem with this &#039;slug&#039; function is when I get to a child, grandChild or deeper. The slug returns the name of that page. : &quot;blueberry&quot; or &quot;bran&quot; and not Products, rendering the CSS background colour useless.  

Thanks in advance for your thoughts.</description>
		<content:encoded><![CDATA[<p>Can I use the recursive script to get a page slug rather than the ID? This would be more useful when applying CSS. </p>
<p>eg: Let&#8217;s say I have two section on my site: About and Products.<br />
About<br />
&#8211;location<br />
&#8211;number of staff<br />
&#8211;hours</p>
<p>Products<br />
&#8211;muffins<br />
    &#8212; blueberry<br />
    &#8212; bran<br />
&#8211;belly button lint collector<br />
&#8211;1.5&#8243;floppy disks</p>
<p>I can add the following function to my function page:<br />
ID, ARRAY_A);<br />
$slug = $post_data['post_name'];<br />
return $slug; }<br />
?&gt;</p>
<p>and this line to my header.php:<br />
&lt;body class=&quot;&#8221;&gt;</p>
<p>Now my page is wrapped in the slug name for the page. This is useful as a sort of &#8216;if&#8221; statement for CSS.<br />
// If this is about page: the header background is blue<br />
// If this is products page: the header background is red </p>
<p>.about .header{background-colour: blue;}<br />
.about .header{background-colour: red;}</p>
<p>This can be done with the ID as  you have it but it&#8217;s not as easy to read:<br />
.about .10{background-color: blue;}</p>
<p>The problem with this &#8216;slug&#8217; function is when I get to a child, grandChild or deeper. The slug returns the name of that page. : &#8220;blueberry&#8221; or &#8220;bran&#8221; and not Products, rendering the CSS background colour useless.  </p>
<p>Thanks in advance for your thoughts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44#comment-10</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Tue, 19 Jan 2010 22:54:43 +0000</pubDate>
		<guid isPermaLink="false">http://andyweigel.com/blog/?p=44#comment-10</guid>
		<description>Awesome function, Jesse. I&#039;ll make sure I add that to my code snippets. Thanks for sharing!</description>
		<content:encoded><![CDATA[<p>Awesome function, Jesse. I&#8217;ll make sure I add that to my code snippets. Thanks for sharing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse</title>
		<link>http://andyweigel.com/blog/wordpress-how-tos/great-grand-parent-ids-in-wordpress/44#comment-9</link>
		<dc:creator>Jesse</dc:creator>
		<pubDate>Tue, 19 Jan 2010 13:08:15 +0000</pubDate>
		<guid isPermaLink="false">http://andyweigel.com/blog/?p=44#comment-9</guid>
		<description>Hey Andy, I&#039;m not sure if you&#039;re familiar with recursion, but just in case there is someone else that comes across this who would like to grab a top element, here&#039;s a function I wrote after discovering that get_post_ancestors only recursed one parent (thus rendering it useless for my needs):

function get_top_ancestor($id){
	$current = get_post($id);
	if(!$current-&gt;post_parent){
		return $current-&gt;ID;
	} else {
		return get_top_ancestor($current-&gt;post_parent);
	}
}

this function will always return the parent, grandparent, or higher, closest to the top. Very good for submenus.</description>
		<content:encoded><![CDATA[<p>Hey Andy, I&#8217;m not sure if you&#8217;re familiar with recursion, but just in case there is someone else that comes across this who would like to grab a top element, here&#8217;s a function I wrote after discovering that get_post_ancestors only recursed one parent (thus rendering it useless for my needs):</p>
<p>function get_top_ancestor($id){<br />
	$current = get_post($id);<br />
	if(!$current-&gt;post_parent){<br />
		return $current-&gt;ID;<br />
	} else {<br />
		return get_top_ancestor($current-&gt;post_parent);<br />
	}<br />
}</p>
<p>this function will always return the parent, grandparent, or higher, closest to the top. Very good for submenus.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
