if( ! function_exists( "is_child" ) ) { function is_child( $parent = '' ) { global $post, $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } if( 0 === $post->post_parent ) return false; if ( is_int( $parent ) && $parent === $post->post_parent ) return true; $parent_obj = get_page( $post->post_parent ); if( ! is_object( $parent_obj ) || is_wp_error( $parent_obj ) ) return false; return $parent === $parent_obj->post_title or $parent === $parent_obj->post_name; } }