搜索解决方案时的一些旁注:
通读this ticket at trac, 参数将随即将发布的版本而更改,以与get_posts()
参数您可以在/core root/wp includes/post中找到该函数。php第3.284行问题:
你确定你没有使用\'include\'
作为论据?此设置\'child_of\'
归零试试这个,告诉我你得到的结果。也许您可以在那里重新订购,直到找到满意的解决方案:
function wpse16921_get_pages( $pages, $r )
{
echo \'<pre>\'; print_r($pages); echo \'</pre>\';
}
add_filter( \'get_pages\', \'wpse16921_get_pages\' );
编辑这里有一组功能可以帮助您解决问题,直到补丁进入wp版本:
// First: Loop through your pages inside the filter
function wpse16921_get_pages_filter( $pages, $r )
{
# echo \'<pre>\';
foreach ( $pages as $page )
{
$page = (array) $page;
$pages_temp[$page[\'post_date\']] = $page;
}
# echo \'Before manipulation: \'; print_r($pages_temp);
$pages_temp = \'/* handle sorting of your new date keys over here */\';
# echo \'After manipulation: \'; print_r($pages_temp);
# echo \'</pre>\';
return $pages = $pages_temp;
}
// Second: Attach the filter to the appropriate hook
function wpse16921_get_pages_filter_hook()
{
add_filter( \'get_pages\', \'wpse16921_get_pages_filter\', 10, 2 );
}
add_action( \'after_setup_theme\', \'wpse16921_get_pages_filter_hook\', 0 );
// Call your pages
function wpse16921_get_pages_call()
{
$pages = get_pages();
# >>>> start modifying/preparing the output
echo \'<pre>\';
foreach ( $pages as $date => $page )
echo $date.\'<br />\';
echo \'</pre>\';
# <<<< end modifying/preparing the output
}
add_action( \'after_setup_theme\', \'wpse16921_get_pages_call\' );