<?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>bavotasan.com &#187; is_child</title>
	<atom:link href="http://bavotasan.com/tag/is_child/feed/" rel="self" type="application/rss+xml" />
	<link>http://bavotasan.com</link>
	<description>by c.bavota</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:42:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>is_child() Conditional Function for WordPress</title>
		<link>http://bavotasan.com/2011/is_child-conditional-function-for-wordpress/</link>
		<comments>http://bavotasan.com/2011/is_child-conditional-function-for-wordpress/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 20:15:04 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[conditional tags]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[is_child]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3351</guid>
		<description><![CDATA[I wrote a little function a while back to Check if a Page is a Child of Another Page in WordPress called is_child(). It used the page ID to return a true or false value dependent on if the current page was a child of the parent page specified. I have recently made a little [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a little function a while back to <a href="http://bit.ly/c4pYxR">Check if a Page is a Child of Another Page in WordPress</a> called <code>is_child()</code>. It used the page ID to return a true or false value dependent on if the current page was a child of the parent page specified. I have recently made a little change so that the function could now accept either a page ID or slug.</p>
<p>Here it is again with the changes:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> is_child<span style="color: #009900;">&#40;</span><span style="color: #000088;">$page_id_or_slug</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span> 
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_int</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page_id_or_slug</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> get_page_by_path<span style="color: #009900;">&#40;</span><span style="color: #000088;">$page_id_or_slug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$page_id_or_slug</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> 
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$page_id_or_slug</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> 
       		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>The modification was inspired by <a href="http://bit.ly/gz0jJj">Helpful Page Functions for WordPress</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/is_child-conditional-function-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

