Paging fixes.
git-svn-id: http://svn.automattic.com/wordpress/trunk@3694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2228ee7b9c
commit
9e83d18a03
|
@ -473,14 +473,16 @@ function _max_num_pages() {
|
||||||
preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
|
preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
|
||||||
$fromwhere = $matches[1];
|
$fromwhere = $matches[1];
|
||||||
$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
|
$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 {
|
} else {
|
||||||
$posts = $wp_query->posts;
|
$posts = $wp_query->posts;
|
||||||
preg_match('#WHERE\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
|
preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
|
||||||
$where = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]);
|
$fromwhere = 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)");
|
$num_days = $wpdb->query("SELECT DISTINCT post_date FROM $fromwhere GROUP BY year(post_date), month(post_date), dayofmonth(post_date)");
|
||||||
return ceil($num_days / get_option('posts_per_page'));
|
$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 »') {
|
function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') {
|
||||||
|
|
Loading…
Reference in New Issue