WordPress: is_subpage()
Quick conditional function for WordPress to check if the current page is a sub page von Matt Varone.
function is_subpage() {
global $post, $wpdb;
if ( is_page() && isset( $post->post_parent ) != 0 ) {
$aParent = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE ID = %d AND post_type = 'page' LIMIT 1", $post->post_parent ) );
if ( $aParent->ID ) return true; else return false;
} else {
return false;
}
} 


