I am using the is_tree function like shown on the wordpress conditional page. I think it used to work, but now somehow does not anymore.
I am calling the function like this and don't get anything.
echo 'is_tree(18) is: '; echo is_tree( '18' );
But don't get a true or a false, but just nothing. What could I be doing wrong? Could this be cause by something else?
Thanks a lot for help with this one. I don't know too much about debugging php. I know the function gets called, but it just doesn't seem to be returning anything.
Here is the actual function:
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 arn't at the page, and the page is not an ancestor
}