您可以使用get_page_children
用于检索所有子页的函数
$the_query = new WP_Query( array( \'post_type\' => \'page\', \'posts_per_page\' => -1 ) );
$children = get_page_children( get_the_ID(), $the_query->query() );
if ( !empty( $children ) ) {
foreach ( $children as $child ) {
// render menu
}
}