我有这个代码来显示页面的子页面及其模板,
<?php
global $wp_query;
// is Page a parent page
if ( $post->post_parent == 0 ) {
// on a parent page, get child pages
$pages = get_pages( \'hierarchical=1&parent=\' . $post->ID );
// loop through child pages
foreach ( $pages as $post ){
setup_postdata( $post );
// get the template name for the child page
$template_name = get_post_meta( $post->ID, \'_wp_page_template\', true );
$template_name = ( \'default\' == $template_name ) ? \'page.php\' : $template_name;
// default page template_part content-page.php
$slug = \'page\';
// check if the slug exists for the child page
if ( locate_template( basename( $template_name ) , $load, $require_once ) != \'\' ) {
$slug = pathinfo( $template_name, PATHINFO_FILENAME );
}
// load the content template for the child page
get_template_part( $slug );
}
}
?>
但它们并没有按照wordpress控制面板中签名给它们的顺序显示。有什么方法可以强制等级秩序吗?