<?php
$id = 123;
$config = array(
'post_parent' => $id ,
'post_type' => 'page',
'numberposts' => -1,
'post_status' => 'publish'
);
$child = get_children($config);
if ($child) {
foreach ($child as $page) {
echo $page->ID;
}
} else {
echo 'Нет дочерних страниц.';
}
?> 'numberposts' => -1 рекурсивно получает все дочерние страницы указанного родителя, если его не указывать, то вернуться лишь те дочерние страницы, у которых parent_id == id родителя:<?php
$id = 1;
$config = [
'parent' => $id,
'post_type' => 'page',
// 'numberposts' => -1,
'post_status' => 'publish',
];
$child = get_pages($config);
if($child) {
foreach($child as $page) {
echo $page->ID;
}
} else {
echo 'У этой страницы нет дочерних страниц.';
} 'numberposts' => 5, или 'numberposts' => 10,. Что значит получить 5 или 10 стр.