Return to Snippet

Revision: 54628
at January 5, 2012 03:52 by madnil


Initial Code
function is_tree($pid) {	// $pid = The ID of the page we're looking for pages underneath
	global $post;			// load details about this page

	if ( is_page($pid) )
		return true;		// we're at the page or at a sub page

	$anc = get_post_ancestors( $post->ID );
	foreach ( $anc as $ancestor ) {
		if( is_page() && $ancestor == $pid ) {
			return true;
		}
	}
	return false;			// we aren't at the page, and the page is not an ancestor
}

Initial URL


Initial Description


Initial Title
Absolute Parent of Any Child Page

Initial Tags
wordpress

Initial Language
PHP