我在自定义主题中就是这样做的:
<h3>Select pages to include in menu:</h3>
<p>
<?php
$page_ids = get_all_page_ids();
$current_selected = get_option("pages_to_include");
foreach( $page_ids as $page_id ) {
if( get_post_status( $page_id ) == \'publish\' ) {
$checked = ( !empty( $current_selected ) && in_array( $page_id, $current_selected ) ) ? \' checked="checked"\' : \'\';
echo \'<input type="checkbox" name="page_to_include[]" id="page-\' . $page_id . \'" value="\' . $page_id . \'"\' . $checked . \' /> <label for="page-\' . $page_id . \'">\' . get_the_title( $page_id ) . \'</label><br />\';
}
}
?>
</p>
将页面列表存储在选项中(以下是
"pages_to_include"
).