get_ancestors
Filters a given object's ancestors.
Usage
add_filter( 'get_ancestors', 'wp_kama_get_ancestors_filter', 10, 4 ); /** * Function for `get_ancestors` filter-hook. * * @param int[] $ancestors An array of IDs of object ancestors. * @param int $object_id Object ID. * @param string $object_type Type of object. * @param string $resource_type Type of resource $object_type is. * * @return int[] */ function wp_kama_get_ancestors_filter( $ancestors, $object_id, $object_type, $resource_type ){ // filter... return $ancestors; }
- $ancestors(int[])
- An array of IDs of object ancestors.
- $object_id(int)
- Object ID.
- $object_type(string)
- Type of object.
- $resource_type(string)
- Type of resource $object_type is.
Changelog
Since 3.1.0 | Introduced. |
Since 4.1.1 | Introduced the $resource_type parameter. |
Where the hook is called
get_ancestors
wp-includes/taxonomy.php 4994
return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
wp-includes/taxonomy.php 4962
return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );