Index: src/wp-includes/link-template.php
===================================================================
--- src/wp-includes/link-template.php	(revision 34827)
+++ src/wp-includes/link-template.php	(working copy)
@@ -1840,10 +1840,11 @@
  */
 function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) {
 	$post = get_post();
-	if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) )
+	if ( ! $post || ! is_singular() || is_attachment() || ! taxonomy_exists( $taxonomy ) )
 		return null;
 
 	$query_args = array(
+		'post_type' => $post->post_type,
 		'posts_per_page' => 1,
 		'order' => $start ? 'ASC' : 'DESC',
 		'update_post_term_cache' => false,
Index: tests/phpunit/tests/link.php
===================================================================
--- tests/phpunit/tests/link.php	(revision 34827)
+++ tests/phpunit/tests/link.php	(working copy)
@@ -173,9 +173,102 @@
 
 		$this->assertEquals( array( $post_two ), get_boundary_post( true, '', true, 'post_tag' ) );
 		$this->assertEquals( array( $post_four ), get_boundary_post( true, '', false, 'post_tag' ) );
+
 	}
 
 	/**
+	 * @ticket 27094
+	 */
+	function test_get_adjacent_post_page() {
+		// Need some sample pages to test adjacency
+		$page_one = $this->factory->post->create_and_get( array(
+			'post_type' => 'page',
+			'post_date' => '2012-01-01 12:00:00'
+		) );
+
+		$page_two = $this->factory->post->create_and_get( array(
+			'post_type' => 'page',
+			'post_date' => '2012-02-01 12:00:00'
+		) );
+
+		$page_three = $this->factory->post->create_and_get( array(
+			'post_type' => 'page',
+			'post_date' => '2012-03-01 12:00:00'
+		) );
+
+		$page_four = $this->factory->post->create_and_get( array(
+			'post_type' => 'page',
+			'post_date' => '2012-04-01 12:00:00'
+		) );
+
+		// Test normal boundary post with pages
+		$this->go_to( get_permalink( $page_two->ID ) );
+
+		$this->assertEquals( array( $page_one ), get_boundary_post( false, '', true ) );
+		$this->assertEquals( array( $page_four ), get_boundary_post( false, '', false ) );
+	}
+
+	/**
+	 * @ticket 27094
+	 */
+	function test_get_adjacent_post_custom_post_type() {
+		// Register a sample custom post type
+		register_post_type( 'wptests_pt', array( 'public' => true ) );
+
+		// Need some sample pages to test adjacency
+		$post_one = $this->factory->post->create_and_get( array(
+			'post_type' => 'wptests_pt',
+			'post_date' => '2012-01-01 12:00:00'
+		) );
+
+		$post_two = $this->factory->post->create_and_get( array(
+			'post_type' => 'wptests_pt',
+			'post_date' => '2012-02-01 12:00:00'
+		) );
+
+		$post_three = $this->factory->post->create_and_get( array(
+			'post_type' => 'wptests_pt',
+			'post_date' => '2012-03-01 12:00:00'
+		) );
+
+		$post_four = $this->factory->post->create_and_get( array(
+			'post_type' => 'wptests_pt',
+			'post_date' => '2012-04-01 12:00:00'
+		) );
+
+		// Test normal boundary post with pages
+		$this->go_to( get_permalink( $post_two->ID ) );
+
+		$this->assertEquals( array( $post_one ), get_boundary_post( false, '', true ) );
+		$this->assertEquals( array( $post_four ), get_boundary_post( false, '', false ) );
+	}
+
+	/**
+	 * @ticket 27094
+	 */
+	function test_get_adjacent_post_attachment() {
+
+		// Need some sample pages to test adjacency
+		$attachment_one = $this->factory->attachment->create_and_get( array(
+			'post_date' => '2012-01-01 12:00:00'
+		) );
+
+		$attachment_two = $this->factory->attachment->create_and_get( array(
+			'post_date' => '2012-02-01 12:00:00'
+		) );
+
+		$attachment_three = $this->factory->attachment->create_and_get( array(
+			'post_date' => '2012-03-01 12:00:00'
+		) );
+
+		// Test normal boundary post with pages
+		$this->go_to( get_permalink( $attachment_two->ID ) );
+
+		$this->assertNull( get_boundary_post( false, '', true ) );
+		$this->assertNull( get_boundary_post( false, '', false ) );
+	}
+
+	/**
 	 * @ticket 22112
 	 */
 	function test_get_adjacent_post_exclude_self_term() {
