Solved it, and decided I could best post my answer here, since people can learn from it 🙂
<?php
global $post;
$children = get_pages( array( 'child_of' => $post->ID ) );
$siblings = get_pages( array( 'child_of' => $post->post_parent ) );
// or, if you want to exclude the current page:
// $siblings = get_pages( array( 'child_of' => $post->post_parent, 'exclude' => $post->ID ) );
if ( is_page() && $post->post_parent > 0 )
{
// Is subpage
if( count( $siblings ) == 0 )
{
// Has no siblings
}
else
{
// Has siblings
echo '<div class="subnav-header">';
echo '<div class="subnav-table">';
echo '<ul>';
foreach($siblings as $sibling){ ?>
<li><a href="https://wordpress.stackexchange.com/questions/241586/<?php echo $sibling->guid; ?>"><?php echo $sibling->post_title; ?></a></li>
<?php }
echo '</ul>';
echo '</div>';
echo '</div>';
}
}
else
{
// Is no subpage
if( count( $children ) == 0 )
{
// Has no children
}
else
{
// Has children
echo '<div class="subnav-header">';
echo '<div class="subnav-table">';
echo '<ul>';
foreach($children as $child){ ?>
<li><a href="https://wordpress.stackexchange.com/questions/241586/<?php echo $child->guid; ?>"><?php echo $child->post_title; ?></a></li>
<?php }
echo '</ul>';
echo '</div>';
echo '</div>';
}
}
?>