您很少需要自定义SQL查询,请使用WordPress提供的工具:
$query = new WP_Query(
array(
\'posts_per_page\' => -1,
\'post_parent\' => $post->ID,
\'post_type\' => \'page\',
\'orderby\' => \'menu_order post_title\',
\'order\' => \'ASC\',
)
);
if ( $query->have_posts() ) : ?>
<?php while ( $query->have_posts() ) : $query->the_post() ?>
<div id="page-<?php the_ID() ?>">
<?php the_content() // Use any template tags as you would normally ?>
</div>
<?php endwhile ?>
<?php wp_reset_postdata() // Restore the current page ?>
<?php endif ?>