Skip to content

Instantly share code, notes, and snippets.

@keeev
Created June 7, 2013 10:30
Show Gist options
  • Save keeev/5728416 to your computer and use it in GitHub Desktop.
Save keeev/5728416 to your computer and use it in GitHub Desktop.
Get ancestor Pages to current page
<?php
$ancestors = get_post_ancestors($post);
if (count($ancestors) >= 1) { // add your hierarchy here
$parent = $ancestors[0];
}
elseif (count($ancestors) >= 2) {
$parent = $ancestors[0];
}
if ($parent) {
$tabs = wp_list_pages('depth=1&sort_column=menu_order&sort_order=desc&child_of=' .$parent."&title_li=");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment