Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannyconnolly/9306905 to your computer and use it in GitHub Desktop.
Save dannyconnolly/9306905 to your computer and use it in GitHub Desktop.
Check if is child page, parent page or ancestor page
/**
* Check if is child page, parent page or ancestor page
*/
function is_in_heirarchy() {
global $wp_query;
if (empty($wp_query->post->post_parent)) {
$parent = $wp_query->post->ID;
} else {
$parent = array_reverse(get_post_ancestors($post->ID));
$parent = $parent[0];
}
if (wp_list_pages("title_li=&child_of=$parent&echo=0")) {
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment