我目前正试图从自定义帖子类型中获取子页面id,但返回的值始终为null。我知道我传递的特定ID有一个父ID,因此应该有一个匹配项。
使用父id获取子id的适当方法是什么?
这就是我所尝试的:
$parentid = $order->get_id();
$args = array(
\'post_parent\' => $parentid,
\'post_type\' => \'shop_subscription\'
);
$child = new WP_Query($args);
if ($child->have_posts()) : while ($child->have_posts()) : $child->the_post();
$childid = get_the_id();
endwhile;
else:
$childid = "not set";
endif;