Skip to content

Instantly share code, notes, and snippets.

@jmsmrgn
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmsmrgn/fee770f9438371c92452 to your computer and use it in GitHub Desktop.
Save jmsmrgn/fee770f9438371c92452 to your computer and use it in GitHub Desktop.
WP - If page parent or child
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