这就是我最后做的,因为我找不到其他方法
//Fetch all pages
$pages = get_pages( array(
\'post_type\' => \'page\',
\'meta_key\' => \'review_date\',
//\'meta_key\' => \'reviewed_by_user_id\',
\'sort_column\' => \'review_date\',
\'sort_order\' => \'asc\'
));
//Fetch metadata for each page
$ordered_pages = array();
foreach ($pages as $page)
{
$metadata = get_metadata(\'post\', $page->ID);
$user = $metadata[\'reviewed_by_user_id\'][0];
$date = $metadata[\'review_date\'][0];
array_push($ordered_pages, array(
\'ID\' => $page->ID,
\'title\' => $page->post_title,
\'review_date\' => $date,
\'reviewed_by_user_id\' => $user,
\'link\' => get_edit_post_link($page->ID),
));
}
//Order the pages
$orderby_array = array();
foreach ($ordered_pages as $key => $row)
{
$orderby_array[$key] = $row[$orderby];
}
array_multisort($orderby_array, SORT_DESC, $ordered_pages);
然后像这样在页面中循环
foreach ($ordered_pages as $page)
{
//Some code
}
这并不漂亮,它使用get\\u metadata调用生成了很多额外的db调用,但由于它在admin中是一个很少查看的页面,所以对我来说没问题。