Created
March 2, 2014 13:56
-
-
Save dannyconnolly/9306905 to your computer and use it in GitHub Desktop.
Check if is child page, parent page or ancestor page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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