Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 29426)
+++ wp-includes/link-template.php	(working copy)
@@ -1500,18 +1500,18 @@
 				return '';
 			$term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
 
+			if ( ! $term_array || is_wp_error( $term_array ) )
+				return '';
+
 			// Remove any exclusions from the term array to include.
 			$term_array = array_diff( $term_array, (array) $excluded_terms );
 			$term_array = array_map( 'intval', $term_array );
 
-			if ( ! $term_array || is_wp_error( $term_array ) )
-				return '';
-
 			$where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")";
 		}
 
 		if ( ! empty( $excluded_terms ) ) {
-			$where .= " AND p.ID NOT IN ( SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN (" . implode( $excluded_terms, ',' ) . ') )';
+			$where .= $wpdb->prepare( " AND tt.taxonomy = %s AND tt.term_id NOT IN (" . implode( $excluded_terms, ',' ) . ')', $taxonomy );
 		}
 	}
 
