--- old/template-functions-links.php	2005-06-11 16:46:17.000000000 +0200
+++ new/template-functions-links.php	2005-06-11 16:45:24.000000000 +0200
@@ -226,7 +226,12 @@
 		}
 	}
 
-	return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT 1");
+	$where = "WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats";
+
+	$where = apply_filters('posts_where', $where);
+	$join = apply_filters('posts_join', $join);
+
+	return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join $where ORDER BY post_date DESC LIMIT 1");
 }
 
 function get_next_post($in_same_cat = false, $excluded_categories = '') {
@@ -259,8 +264,12 @@
 	}
 
 	$now = current_time('mysql');
+	$where = " WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID";
+
+	$where = apply_filters('posts_where', $where);
+	$join = apply_filters('posts_join', $join);
     
-	return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT 1");
+	return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join $where ORDER BY post_date ASC LIMIT 1");
 }
 
 function previous_post_link($format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {

