diff --git wp-includes/post.php wp-includes/post.php
index 2be10a1db6..5b39914377 100644
--- wp-includes/post.php
+++ wp-includes/post.php
@@ -5614,6 +5614,12 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
 	// Delete all for any posts.
 	delete_metadata( 'post', null, '_thumbnail_id', $post_id, true );
 
+	$site_icon_id = get_option( 'site_icon' );
+
+	if ( $site_icon_id && $post_id == $site_icon_id ) {
+		delete_option( 'site_icon' );
+	}
+
 	wp_defer_comment_counting( true );
 
 	$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );
