Last active
December 5, 2018 07:11
-
-
Save oliwa/287a507dc42a074bf62d to your computer and use it in GitHub Desktop.
WP: is_tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_tree($pid) | |
{ | |
global $post; | |
$ancestors = get_post_ancestors($post->$pid); | |
$root = count($ancestors) - 1; | |
$parent = $ancestors[$root]; | |
if(is_page() && (is_page($pid) || $post->post_parent == $pid || in_array($pid, $ancestors))) | |
{ | |
return true; | |
} | |
else | |
{ | |
return false; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment