From 4d5eb321e71f769fa0a21d1a76ebaedad43844a5 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 5 Apr 2006 20:48:29 +0000 Subject: [PATCH] Paging fixes. git-svn-id: https://develop.svn.wordpress.org/trunk@3694 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/template-functions-links.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wp-includes/template-functions-links.php b/wp-includes/template-functions-links.php index d2beb5ffd4..9d025a1d6e 100644 --- a/wp-includes/template-functions-links.php +++ b/wp-includes/template-functions-links.php @@ -473,14 +473,16 @@ function _max_num_pages() { preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches); $fromwhere = $matches[1]; $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); - return ceil($numposts / get_option('posts_per_page')); + $max_num_pages = ceil($numposts / get_option('posts_per_page')); } else { $posts = $wp_query->posts; - preg_match('#WHERE\s(.*)\sORDER BY#siU', $wp_query->request, $matches); - $where = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]); - $num_days = $wpdb->query("SELECT DISTINCT post_date FROM $wpdb->posts WHERE $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date)"); - return ceil($num_days / get_option('posts_per_page')); + preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches); + $fromwhere = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]); + $num_days = $wpdb->query("SELECT DISTINCT post_date FROM $fromwhere GROUP BY year(post_date), month(post_date), dayofmonth(post_date)"); + $max_num_pages = ceil($num_days / get_option('posts_per_page')); } + + return $max_num_pages; } function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') {