diff --git src/wp-includes/link-template.php src/wp-includes/link-template.php
index 365b14b..13619d2 100644
--- src/wp-includes/link-template.php
+++ src/wp-includes/link-template.php
@@ -1682,6 +1682,18 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
 	$where    = '';
 	$adjacent = $previous ? 'previous' : 'next';
 
+	if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) {
+		// back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
+		if ( false !== strpos( $excluded_terms, ' and ' ) ) {
+			_deprecated_argument( __FUNCTION__, '3.3.0', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
+			$excluded_terms = explode( ' and ', $excluded_terms );
+		} else {
+			$excluded_terms = explode( ',', $excluded_terms );
+		}
+
+		$excluded_terms = array_map( 'intval', $excluded_terms );
+	}
+
 	/**
 	 * Filters the IDs of terms excluded from adjacent post queries.
 	 *
@@ -1695,18 +1707,6 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
 	$excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms );
 
 	if ( $in_same_term || ! empty( $excluded_terms ) ) {
-		if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) {
-			// back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
-			if ( false !== strpos( $excluded_terms, ' and ' ) ) {
-				_deprecated_argument( __FUNCTION__, '3.3.0', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
-				$excluded_terms = explode( ' and ', $excluded_terms );
-			} else {
-				$excluded_terms = explode( ',', $excluded_terms );
-			}
-
-			$excluded_terms = array_map( 'intval', $excluded_terms );
-		}
-
 		if ( $in_same_term ) {
 			$join  .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
 			$where .= $wpdb->prepare( 'AND tt.taxonomy = %s', $taxonomy );
