wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

Return ID if parent page exists

wordpress snippet

This is a great little snippet that will let you return the ID of the parent page if the page has a parent. Just add this snippet to the functions.php of your wordpress theme and your ready to get the parent page ID.

snippet :  PHPcopy
function is_subpage() {
    global $post;
    if ( is_page() && $post->post_parent ) {
        return $post->post_parent;
    } else {
        return false;
source →

Did you like this post? If so please share it with your friends. Thanks!