wpseek.com
WordPress开发者和主题制作者的搜索引擎
get_page_hierarchy › WordPress Function
Since2.0.0
已弃用n/a
› get_page_hierarchy ( $pages, $page_id = 0 )
| 参数: (2) |
|
| 返回: |
|
| 定义在: |
|
| 文档: |
Orders the pages with children under parents in a flat list.
It uses auxiliary structure to hold parent-children relationships and runs in O(N) complexityRelated Functions: get_template_hierarchy, _get_term_hierarchy, get_page_uri, get_page_link, _get_page_link
源码
function get_page_hierarchy( &$pages, $page_id = 0 ) {
if ( empty( $pages ) ) {
return array();
}
$children = array();
foreach ( (array) $pages as $p ) {
$parent_id = (int) $p->post_parent;
$children[ $parent_id ][] = $p;
}
$result = array();
_page_traverse_name( $page_id, $children, $result );
return $result;
}