Index: src/wp-includes/link-template.php
===================================================================
--- src/wp-includes/link-template.php	(revision 34827)
+++ src/wp-includes/link-template.php	(working copy)
@@ -1844,6 +1844,7 @@
 		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,70 @@
 
 		$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_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() {
