Last active
October 6, 2015 02:38
-
-
Save hissy/2921663 to your computer and use it in GitHub Desktop.
check the page is a SubPage #WordPress
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
<?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