$parent_id,
'sort_column' => 'menu_order, post_title',
'sort_order' => 'ASC',
]);
if (empty($children)) return;
$indent = str_repeat(' ', $depth);
echo $indent . '
';
foreach ($children as $child) {
$is_current = ($child->ID === $current_id);
$has_children = (int) get_pages(['child_of' => $child->ID, 'parent' => $child->ID, 'hide_empty' => true, 'fields' => 'ids']) > 0;
echo $indent . ' - ';
echo '' . esc_html($child->post_title) . '';
if ($has_children && $depth < 3) {
aksrt_render_doc_tree($child->ID, $current_id, $depth + 1);
}
echo '
';
}
echo $indent . '
';
}
}
$current_id = get_the_ID();
$root_id = wp_get_post_parent_id($current_id) ?: $current_id;
?>