您的当前位置:首页 > 知识博客 > wordpress建站

WordPress获取页面ID、名称列表函数:get_page_hierarchy

时间:2024-03-09

WordPress函数get_page_hierarchy以页面ID为键,名称为值返回页面列表数组。

get_page_hierarchy( WP_Post[] $pages, int $page_id )

函数参数

$pages

数组

页面列表对象,用get_pages()函数获取

$page_id

整数,默认值:0

父页面ID,仅返回指定ID页面的子页面。

函数返回值

Array
(
    [2] => about
    [10] => job
    [15] => contact
    [13] => links
    [8] => service
)

函数使用示例

$all_pages = get_pages( array(
	'post_type'         => 'page',
	'post_status'       => array( 'publish' )
) );
$page_list = get_page_hierarchy($all_pages);

扩展阅读

get_page_hierarchy()函数位于:wp-includes/post.php

相关函数:

  • page_traverse_name()

  • get_pages()

  • get_children()


欢迎咨询/Welcome to inquire
tel/vx:18842938855
qq:1685522781
email:1685522781@qq.com

Copyright © 2019-2024 sex.cyou


Whatsapp
Powered by RRZCMS