diff --git a/src/wp-includes/canonical.php b/src/wp-includes/canonical.php
index 184fb756e8..aea6bf889d 100644
--- a/src/wp-includes/canonical.php
+++ b/src/wp-includes/canonical.php
@@ -952,7 +952,7 @@ function redirect_guess_404_permalink() {
 		}
 
 		// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
-		$post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'" );
+		$post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status IN ('" . implode( "', '", get_post_stati( array( 'public' => true ) ) ) . "')" );
 
 		if ( ! $post_id ) {
 			return false;
diff --git a/tests/phpunit/tests/canonical.php b/tests/phpunit/tests/canonical.php
index bd0b68c038..8cd0d973e8 100644
--- a/tests/phpunit/tests/canonical.php
+++ b/tests/phpunit/tests/canonical.php
@@ -275,6 +275,26 @@ class Tests_Canonical extends WP_Canonical_UnitTestCase {
 		$this->assertFalse( redirect_guess_404_permalink() );
 	}
 
+	/**
+	 * Ensure public posts with custom statuses are guessed
+	 *
+	 * @ticket 47911
+	 */
+	public function test_redirect_guess_404_permalink_with_custom_status_public() {
+		register_post_status( 'custom', array( 'public' => true ) );
+
+		$post = self::factory()->post->create(
+			array(
+				'post_title'  => 'custom-status-public-guess-404-permalink',
+				'post_status' => 'custom',
+			)
+		);
+
+		$this->go_to( 'custom-status-public-guess-404-permalink' );
+
+		$this->assertSame( get_permalink( $post ), redirect_guess_404_permalink() );
+	}
+
 	/**
 	 * Ensure multiple post types do not throw a notice.
 	 *
