Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active October 6, 2015 02:38
Show Gist options
  • Save hissy/2921663 to your computer and use it in GitHub Desktop.
Save hissy/2921663 to your computer and use it in GitHub Desktop.
check the page is a SubPage #WordPress
<?php
/*
* Usage
* if ( is_subpage( get_the_ID() ) :
* // subpage
* else:
* // not a subpage
* endif;
*/
function is_subpage( $post ) {
$post = get_post( $post );
if ( !$post || is_wp_error( $post ) )
return false;
if ( is_page() && $post->post_parent ) { return true; } // Is a SubPage
else { return false; } // Not a SubPage
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment