wordpress check if current page is the only grand child
I am trying to do a statement that checks whether the current page is the only grand child page in wordpress and cannot seem to wrap my head around it.
ie 2 levels deep
parent > child > grandchild
if there is more than 1 grandchild page, perform action.
$siblings = get_posts(array( 'exclude' => array($post->ID), 'post_type' => $post->post_type, 'post_parent' => $post->post_parent, 'numberposts' => 1 // we're only checking if there ARE siblings, so save a little memory )); $is_only_child = empty($siblings);