get_ancestors

SummerySummery

Get an array of ancestor IDs for a given object.

Syntax

get_ancestors( int $object_id, string $object_type = '', string $resource_type = '' )

ParametersParameters

$object_id

(int) (Optional) The ID of the object. Default 0.

$object_type

(string) (Optional) The type of object for which we'll be retrieving ancestors. Accepts a post type or a taxonomy name.

Default value: ''

$resource_type

(string) (Optional) Type of resource $object_type is. Accepts 'post_type' or 'taxonomy'.

Default value: ''

ReturnReturn

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

SourceSource

File: wp-includes/taxonomy.php


			

ChangelogChangelog

Changelog
Version Description
4.1.0 Introduced the $resource_type argument.
3.1.0 Introduced.
Scroll to Top