Skip to content

Instantly share code, notes, and snippets.

@gagimilicevic
Created May 8, 2018 14:38
Show Gist options
  • Save gagimilicevic/2f664e1d788886f1fdd0d54052ad89da to your computer and use it in GitHub Desktop.
Save gagimilicevic/2f664e1d788886f1fdd0d54052ad89da to your computer and use it in GitHub Desktop.
Snippet that will let you return the ID of the parent page if the page has a parent.
<?php
function is_subpage() {
global $post;
if ( is_page() && $post->post_parent ) {
return $post->post_parent;
} else {
return false;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment