Skip to content

Instantly share code, notes, and snippets.

@jgwhite
Created November 20, 2011 16:29
Show Gist options
  • Select an option

  • Save jgwhite/1380441 to your computer and use it in GitHub Desktop.

Select an option

Save jgwhite/1380441 to your computer and use it in GitHub Desktop.
WP Argghhhh
<?php
function get_current_depth() {
global $wp_query;
$object = $wp_query->get_queried_object();
$parent_id = $object->post_parent;
$depth = 0;
while ($parent_id > 0) {
$page = get_page($parent_id);
$parent_id = $page->post_parent;
$depth++;
}
return $depth;
}
?>
<?php
if (get_current_depth() > 2) {
wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=1");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment