wp_post->post_parent object returning 0

kraftner is probably right but I recommand you to stop using global $post. I mean it’s not bad but there are often issues with this big array that can be modified by almost everything running on the wp install.

So to me it’s not very safe. I prefer using get_queried_object() and it works quite the same way :

$parent_ID = get_queried_object()->post_parent;

It retrieves data according to the current page. It uses the global $wp_query instead. Be careful here we try to get post_parent property so don’t run this code on a category page you’d get a warning.