This should work. I’m not entirely sure what is wrong with your code (it’s getting late) but the below code works on my end. Obviously I replaced $order->get_id()
with a known ID and post_type
was set to page
.
<?php
$parentid = $order->get_id();
$child = new WP_Query( array('post_parent' => $parentid, 'post_type' => 'shop_subscription') );
if ($child->have_posts()) : while ($child->have_posts()) : $child->the_post();
$childid = get_the_ID();
endwhile;
else:
$childid = "not set";
endif;
wp_reset_query();
?>