From 1556042c0800926fe2dffe719cf284f5bc4760c9 Mon Sep 17 00:00:00 2001 From: mikelittle Date: Wed, 23 Jul 2003 21:04:25 +0000 Subject: [PATCH] previous/next_post don't link to non-published posts. Fix by Alex King git-svn-id: http://svn.automattic.com/wordpress/trunk@268 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- b2-include/b2template.functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/b2-include/b2template.functions.php b/b2-include/b2template.functions.php index 1ca021e278..3c0f4214e4 100644 --- a/b2-include/b2template.functions.php +++ b/b2-include/b2template.functions.php @@ -618,7 +618,7 @@ function previous_post($format='%', $previous='previous post: ', $title='yes', $ } $limitprev--; - $lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $tableposts WHERE post_date < '$current_post_date' AND post_category > 0 $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1"); + $lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $tableposts WHERE post_date < '$current_post_date' AND post_category > 0 AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1"); ++$querycount; if ($lastpost) { $string = ''.$previous; @@ -659,7 +659,7 @@ function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat= $limitnext--; - $nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $tableposts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_category > 0 $sqlcat $sql_exclude_cats ORDER BY post_date ASC LIMIT $limitnext,1"); + $nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $tableposts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_category > 0 AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date ASC LIMIT $limitnext,1"); ++$querycount; if ($nextpost) { $string = ''.$next;