<?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: Get Depth &#8211; like is_child() &amp; is_grandchild()</title>
	<atom:link href="http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 05 Oct 2011 04:38:51 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: jon</title>
		<link>http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/comment-page-1/#comment-16536</link>
		<dc:creator>jon</dc:creator>
		<pubDate>Mon, 22 Aug 2011 15:10:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-templates.nu/?p=37#comment-16536</guid>
		<description>I think you can solve all this easily using get_ancestors().

$depth = count(get_ancestors($post, &#039;post&#039;));</description>
		<content:encoded><![CDATA[<p>I think you can solve all this easily using get_ancestors().</p>
<p>$depth = count(get_ancestors($post, &#8216;post&#8217;));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Get Current Page Depth &#171; World Web Corner.com</title>
		<link>http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/comment-page-1/#comment-15633</link>
		<dc:creator>Get Current Page Depth &#171; World Web Corner.com</dc:creator>
		<pubDate>Sun, 17 Jul 2011 06:31:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-templates.nu/?p=37#comment-15633</guid>
		<description>[...] Put the following code to the functions.php in your WordPress theme folder. Source [...]</description>
		<content:encoded><![CDATA[<p>[...] Put the following code to the functions.php in your WordPress theme folder. Source [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George Crane</title>
		<link>http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/comment-page-1/#comment-13133</link>
		<dc:creator>George Crane</dc:creator>
		<pubDate>Tue, 19 Apr 2011 17:08:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-templates.nu/?p=37#comment-13133</guid>
		<description>Thanks so much for this - saved me hours!
Cheers BigG</description>
		<content:encoded><![CDATA[<p>Thanks so much for this &#8211; saved me hours!<br />
Cheers BigG</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mcjambi</title>
		<link>http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/comment-page-1/#comment-12092</link>
		<dc:creator>mcjambi</dc:creator>
		<pubDate>Tue, 15 Mar 2011 02:01:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-templates.nu/?p=37#comment-12092</guid>
		<description>thanks so much ! my friend ! i copy it and you will see your copyright : http://muasamvui.com/f/get-depth-of-the-menu-like-is-child-is-grandchild-t3226.html</description>
		<content:encoded><![CDATA[<p>thanks so much ! my friend ! i copy it and you will see your copyright : <a href="http://muasamvui.com/f/get-depth-of-the-menu-like-is-child-is-grandchild-t3226.html" rel="nofollow">http://muasamvui.com/f/get-depth-of-the-menu-like-is-child-is-grandchild-t3226.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ola</title>
		<link>http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/comment-page-1/#comment-6066</link>
		<dc:creator>Ola</dc:creator>
		<pubDate>Fri, 26 Feb 2010 21:09:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-templates.nu/?p=37#comment-6066</guid>
		<description>Wow, this really helped me out a lot..thanks!!!  :D</description>
		<content:encoded><![CDATA[<p>Wow, this really helped me out a lot..thanks!!!  <img src='http://www.web-templates.nu/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tristan</title>
		<link>http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/comment-page-1/#comment-5882</link>
		<dc:creator>Tristan</dc:creator>
		<pubDate>Fri, 29 Jan 2010 05:31:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-templates.nu/?p=37#comment-5882</guid>
		<description>To return just the level below the current page you need this:
get_pages(&#039;child_of=&#039;.$post-&gt;ID.&#039;&amp;parent=&#039;.$post-&gt;ID);
foreach ($pages as $page) {

//something in here

}

Hope this helps :)</description>
		<content:encoded><![CDATA[<p>To return just the level below the current page you need this:<br />
get_pages(&#8216;child_of=&#8217;.$post-&gt;ID.&#8217;&amp;parent=&#8217;.$post-&gt;ID);<br />
foreach ($pages as $page) {</p>
<p>//something in here</p>
<p>}</p>
<p>Hope this helps <img src='http://www.web-templates.nu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chrille</title>
		<link>http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/comment-page-1/#comment-5798</link>
		<dc:creator>Chrille</dc:creator>
		<pubDate>Tue, 19 Jan 2010 13:43:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-templates.nu/?p=37#comment-5798</guid>
		<description>Hi!

If you would like too get a different echo for each parent/grandparent? How would you do that and where should i put the code?

My page is : http://trollback.se/urskog/products/lov/walnut/

So I want headerMeny to be highlighted and &quot;lov&quot; when on a subpage to them. So how should i code this?
This is a extract from my current meny:

&lt;li class=&quot;mainNav_Lov&quot;&gt;
					&lt;a href=&quot;/products/lov/walnut&quot;&gt;&lt;/a&gt;
				

THIS IS MY HEADER MENY:

                       &lt;li class=&quot;products&quot;&gt;
                &lt;a href=&quot;/products/lov/walnut&quot;&gt;&lt;/a&gt;
        	

Basicly I want to get &quot;LÖV&quot; highlighed with :  id = current2 
and I want Products to be hlighlighted  : id= current

Thank you!</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>If you would like too get a different echo for each parent/grandparent? How would you do that and where should i put the code?</p>
<p>My page is : <a href="http://trollback.se/urskog/products/lov/walnut/" rel="nofollow">http://trollback.se/urskog/products/lov/walnut/</a></p>
<p>So I want headerMeny to be highlighted and &#8220;lov&#8221; when on a subpage to them. So how should i code this?<br />
This is a extract from my current meny:</p>
<p>&lt;li class=&quot;mainNav_Lov&quot;&gt;<br />
					&lt;a href=&quot;/products/lov/walnut&#8221;&gt;</p>
<p>THIS IS MY HEADER MENY:</p>
<p>                       &lt;li class=&quot;products&quot;&gt;<br />
                &lt;a href=&quot;/products/lov/walnut&#8221;&gt;</p>
<p>Basicly I want to get &#8220;LÖV&#8221; highlighed with :  id = current2<br />
and I want Products to be hlighlighted  : id= current</p>
<p>Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph</title>
		<link>http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/comment-page-1/#comment-3256</link>
		<dc:creator>Joseph</dc:creator>
		<pubDate>Thu, 09 Jul 2009 16:31:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-templates.nu/?p=37#comment-3256</guid>
		<description>Thanks for the function! Saved me a headache.</description>
		<content:encoded><![CDATA[<p>Thanks for the function! Saved me a headache.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vybes</title>
		<link>http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/comment-page-1/#comment-3164</link>
		<dc:creator>vybes</dc:creator>
		<pubDate>Mon, 29 Jun 2009 19:14:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-templates.nu/?p=37#comment-3164</guid>
		<description>hey, thank you for the code. i was looking for a code to check the depth of a category, i tweaked your code and it helped solve a problem i was trying to solve.big up.

here is the code to get the depth of categories;

function wt_get_depth($id = &#039;&#039;, $depth = &#039;&#039;, $i = 0)
{
	global $wpdb;
	global $term_taxonomy;

	if($depth == &#039;&#039;)
	{
		if(is_category())
		{
			if($id == &#039;&#039;)
			{
				$id = $term_taxonomy-&gt;term_id;
			}
			$depth = $wpdb-&gt;get_var(&quot;SELECT parent FROM $wpdb-&gt;term_taxonomy WHERE term_id = &#039;&quot;.$id.&quot;&#039;&quot;);
			return wt_get_depth($id, $depth, $i);
		}
	}
	elseif($depth == &quot;0&quot;)
	{
		return $i;
	}
	else
	{
		$depth = $wpdb-&gt;get_var(&quot;SELECT parent FROM $wpdb-&gt;term_taxonomy WHERE term_id = &#039;&quot;.$depth.&quot;&#039;&quot;);
		$i++;
		return wt_get_depth($id, $depth, $i);
	}
}</description>
		<content:encoded><![CDATA[<p>hey, thank you for the code. i was looking for a code to check the depth of a category, i tweaked your code and it helped solve a problem i was trying to solve.big up.</p>
<p>here is the code to get the depth of categories;</p>
<p>function wt_get_depth($id = &#8221;, $depth = &#8221;, $i = 0)<br />
{<br />
	global $wpdb;<br />
	global $term_taxonomy;</p>
<p>	if($depth == &#8221;)<br />
	{<br />
		if(is_category())<br />
		{<br />
			if($id == &#8221;)<br />
			{<br />
				$id = $term_taxonomy-&gt;term_id;<br />
			}<br />
			$depth = $wpdb-&gt;get_var(&#8220;SELECT parent FROM $wpdb-&gt;term_taxonomy WHERE term_id = &#8216;&#8221;.$id.&#8221;&#8216;&#8221;);<br />
			return wt_get_depth($id, $depth, $i);<br />
		}<br />
	}<br />
	elseif($depth == &#8220;0&#8243;)<br />
	{<br />
		return $i;<br />
	}<br />
	else<br />
	{<br />
		$depth = $wpdb-&gt;get_var(&#8220;SELECT parent FROM $wpdb-&gt;term_taxonomy WHERE term_id = &#8216;&#8221;.$depth.&#8221;&#8216;&#8221;);<br />
		$i++;<br />
		return wt_get_depth($id, $depth, $i);<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marty Thornley</title>
		<link>http://www.web-templates.nu/2008/09/07/get-depth-like-is_child-is_grandchild/comment-page-1/#comment-3073</link>
		<dc:creator>Marty Thornley</dc:creator>
		<pubDate>Mon, 15 Jun 2009 21:34:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-templates.nu/?p=37#comment-3073</guid>
		<description>Copied the wrong code... Oops.

the line finding the parent of the post should be:

if ($post-&gt;post_parent) $parent = $post-&gt;post_parent;

not:

if ($post-&gt;post_parent) $parent = get_page($post-&gt;post_parent);</description>
		<content:encoded><![CDATA[<p>Copied the wrong code&#8230; Oops.</p>
<p>the line finding the parent of the post should be:</p>
<p>if ($post-&gt;post_parent) $parent = $post-&gt;post_parent;</p>
<p>not:</p>
<p>if ($post-&gt;post_parent) $parent = get_page($post-&gt;post_parent);</p>
]]></content:encoded>
	</item>
</channel>
</rss>

