I have registered a custom post type with settings 'hierarchical' => true and 'supports' => array('title', 'editor', 'page-attributes')
The intention is to use this post type for hierarchical posts much like the "page" post type.
I have two posts with the following data:
When I visit the URL /custom-post-type/post-slug-here/ you expect to see "Post 1", however it is actually "Post 2" being served up by WordPress.
A quick dump of $wp_query shows that WordPress has found both "Post 1" and "Post 2" in its request, however it has incorrectly decided to use "Post 2" for the $post variable.
The request should really order by post_parent ASC, this way always prioritising the post with post_parent = 0 over a subpage