$child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY menu_order", 'OBJECT');
if ( $child_pages ) :
$count = 1;
foreach ( $child_pages as $pageChild ) :
setup_postdata( $pageChild );
$thumbnail = get_the_post_thumbnail($pageChild->ID, 'magazine-small-image');
if($thumbnail == "") continue; // Skip pages without a thumbnail
?>
if ( $count % 3 == 0 ) {
echo '
';
}
$count++ ;
endforeach;
endif;
?>