Created
September 29, 2014 16:23
-
-
Save Kenshino/1f3d7943a1bc46ead5f4 to your computer and use it in GitHub Desktop.
page sub menu functions
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
function get_top_parent_page_id() { | |
global $post; | |
// Check if page is a child page (any level) | |
if ($post->ancestors) { | |
// Grab the ID of top-level page from the tree | |
return end($post->ancestors); | |
} else { | |
// Page is the top level, so use it's own id | |
return $post->ID; | |
} | |
} | |
function is_subpage() { | |
global $post; // load details about this page | |
if ( is_page() && $post->post_parent ) { // test to see if the page has a parent | |
return $post->post_parent; // return the ID of the parent post | |
} else { // there is no parent so ... | |
return false; // ... the answer to the question is false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment