Languages: English • 한국어 • 日本語 (Add your language)
Returns an array containing the parents of the given object.
<?php get_ancestors( $object_id, $object_type, $resource_type ); ?>
<?php $ancestors = get_ancestors( 6, 'page', 'post_type' ); ?>
Given the following category hierarchy (with IDs):
<?php get_ancestors( 208, 'category' ); ?>
returns:
Array
(
[0] => 23
[1] => 6
)
Given the a page hierarchy (with IDs):
<?php get_ancestors( 448, 'page' ); ?>
returns:
Array
(
[0] => 447
)
get_ancestors() is located in 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()