有一个主要职位:
$parent = wp_insert_post([
\'post_type\' => \'parent\',
\'post_name\' => \'test parent\'
]);
孩子们:
$child1 = wp_insert_post([
\'post_type\' => \'child\',
\'post_name\' => \'test child1\'
]);
$child2 = wp_insert_post([
\'post_type\' => \'child\',
\'post_name\' => \'test child2\'
]);
$child3 = wp_insert_post([
\'post_type\' => \'child\',
\'post_name\' => \'test child3\'
]);
让我们匹配它们:
wp_update_post(
array(\'ID\' => $child1, \'post_parent\' => $parent)
);
wp_update_post(
array(\'ID\' => $child2, \'post_parent\' => $parent)
);
wp_update_post(
array(\'ID\' => $child3, \'post_parent\' => $parent)
);
最后列出:
$children = get_children([\'post_parent\' => $parent]);
这在理论上似乎是可以的,但它只描述了关系本身,而不是顺序。如果我想命令孩子们怎么办?怎么做?