Codex tools: Log in
Contents |
Returns an array containing the parents of the given object.
<?php get_ancestors( $object_id, $object_type ); ?>
<?php get_ancestors(
'object_id' => 6,
'object_type' => 'page' ); ?>
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()