KoderyBeta

If is_subpage Function

Category: WordPress - Owner: PaulDavis - Owner ID: 1

Checks to see if page is either a sub-page, or sub-page to perticular page.

http://www.mattvarone.com/wordpress/is_subpage-function/

function is_subpage(){
	global $post, $wpdb;
		if ( is_page() AND 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;
	}
}