WPDev.one
Core Function
View Source on Trac ↗

get_ancestors()

get_ancestors( mixed $object_id = 0, mixed $object_type = '', mixed $resource_type = '' )

Gets an array of ancestor IDs for a given object.

Parameters 2 required

Name / Type Description
$object_id
int

Optional. The ID of the object. Default 0.

string

$object_type Optional. The type of object for which we'll be retrieving ancestors. Accepts a post type or a taxonomy name. Default empty.

Required
string

$resource_type Optional. Type of resource $object_type is. Accepts 'post_type' or 'taxonomy'. Default empty.

Required

Return Value

(int[])
An array of IDs of ancestors from lowest to highest in the hierarchy.

Function Information

Since Version
3.1.0
Source File
wp-includes/taxonomy.php
Advertisement