Parent or child (wordpress)

Check if a page is a parent or any descendant of a parent.

<?php
/**
 * Check if a page is parent or child.
 */
function is_tree($pid) {
  if (!is_page()) {
    return false;
  }
  return is_page($pid) || in_array($pid, get_post_ancestors(get_the_ID()));
}
?>

functions.php

< toolbox