Additional function for WordPress: is_parent()

November 19th, 2011


I was in need of a wordpress function to check is current page child of specific page or not. WordPress doesnt offer a function like is_parent() and wrote mine. I hope it would help you too.

function is_parent( $parent_id, $post_id ) {
  if (get_post($post_id)->post_parent == $parent_id){
    return true;
  } else {
    return false;
  }
}