与注释一样,唯一的方法是使用自定义sql查询,因此:
global $wpdb;
$mypages = $wpdb->get_results( "SELECT post_title, post_name FROM $wpdb->posts
WHERE post_type = \'page\'
AND post_status = \'publish\'
AND parent = \'0\'");
if (count($mypages) > 0){
foreach ($mypages as $page){
//do you stuff
//$page[\'post_title\'] for title
//$page[\'post_name\'] for slug
}
}