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.

Answers


$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);

Need Your Help

Button inside swing Rectangle2D.double

java swing button hyperlink

We have a swing application which displays a lot of rectangles. We use Rectangle2D.double class to draw the rectangles on a JPanel.

Django query - Retrieve objects that don't have other object pointing to them

python django

I've got a model named String that looks something like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.