WordPress函数文档get_ancestors()

获取当前分类/页面/链接的父级节点信息 描述 Returns an array containing the …

获取当前分类/页面/链接的父级节点信息

描述

Returns an array containing the parents of the given object.

用法

 <?php get_ancestors$object_id$object_type ); ?> 

Default Usage

 <?php $ancestors get_ancestors6'page' ); ?> 

参数

$object_id

(int or string) (必填) The ID of the child object

默认值: None

$object_type

(string) (必填) The name of the object type (page, hierarchical post type, category, or hierarchical taxonomy) in question

默认值: None

返回值

(array) 

Array of ancestors from lowest to highest in the hierarchy

示例

Given the following category hierarchy (with IDs):

  • Books (6)
    • Fiction (23)
      • Mystery (208)

returns:

 Array
(
    [0] => 23
    [1] => 6

Given the a page hierarchy (with IDs):

  • About (447)
    • Child Page (448)

returns:

  Array
(
    [0] => 447

注意

  • Filter: get_ancestors is applied to ancestors array before it is returned.

历史

  • 添加于 版本: 3.1.0

源文件

get_ancestors() 函数的代码位于 wp-includes/taxonomy.php.

相关

Page Tags: get_all_page_ids(),
get_ancestors(),
get_page(),
get_page_link(),
get_page_by_path(),
get_page_by_title(),
get_page_children(),
get_page_hierarchy(),
get_page_uri(),
get_pages(),
is_page(),
page_uri_index(),
wp_list_pages(),
wp_page_menu()

  • 原文:http://codex.wordpress.org/Function_Reference/get_ancestors
类别:WordPress函数文档

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT