fixed next_posts_links, removed debug artefacts lying there
git-svn-id: http://svn.automattic.com/wordpress/trunk@1785 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f1cd47763b
commit
a00764ed8e
|
@ -504,14 +504,9 @@ function next_posts($max_page = 0) { // original by cfactor at cooltux.org
|
||||||
function next_posts_link($label='Next Page »', $max_page=0) {
|
function next_posts_link($label='Next Page »', $max_page=0) {
|
||||||
global $paged, $result, $request, $posts_per_page, $wpdb;
|
global $paged, $result, $request, $posts_per_page, $wpdb;
|
||||||
if (!$max_page) {
|
if (!$max_page) {
|
||||||
$nxt_request = $request;
|
preg_match('#WHERE (.*) GROUP BY#', $request, $matches);
|
||||||
//if the query includes a limit clause, call it again without that
|
$where = $matches[1];
|
||||||
//limit clause!
|
$numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE $where");
|
||||||
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
|
|
||||||
$nxt_request = substr($request, 0, $pos);
|
|
||||||
}
|
|
||||||
$nxt_result = $wpdb->query($nxt_request);
|
|
||||||
$numposts = $wpdb->num_rows;
|
|
||||||
$max_page = ceil($numposts / $posts_per_page);
|
$max_page = ceil($numposts / $posts_per_page);
|
||||||
}
|
}
|
||||||
if (!$paged)
|
if (!$paged)
|
||||||
|
@ -545,38 +540,12 @@ function previous_posts_link($label='« Previous Page') {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function posts_nav_link_old($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') {
|
|
||||||
global $request, $posts_per_page, $wpdb;
|
|
||||||
if (! is_single()) {
|
|
||||||
$show_what = get_query_var('what_to_show');
|
|
||||||
|
|
||||||
if (get_query_var('what_to_show') == 'posts') {
|
|
||||||
$nxt_request = $request;
|
|
||||||
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
|
|
||||||
$nxt_request = substr($request, 0, $pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
$nxt_result = $wpdb->query($nxt_request);
|
|
||||||
$numposts = $wpdb->num_rows;
|
|
||||||
$max_page = ceil($numposts / $posts_per_page);
|
|
||||||
} else {
|
|
||||||
$max_page = 999999;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($max_page > 1) {
|
|
||||||
previous_posts_link($prelabel);
|
|
||||||
echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $sep);
|
|
||||||
next_posts_link($nxtlabel, $max_page);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') {
|
function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') {
|
||||||
global $request, $posts_per_page, $wpdb;
|
global $request, $posts_per_page, $wpdb;
|
||||||
if (! is_single()) {
|
if (! is_single()) {
|
||||||
|
|
||||||
if (get_query_var('what_to_show') == 'posts') {
|
if (get_query_var('what_to_show') == 'posts') {
|
||||||
preg_match('#WHERE 1=1 AND (.*)GROUP BY#', $request, $matches);
|
preg_match('#WHERE (.*) GROUP BY#', $request, $matches);
|
||||||
$where = $matches[1];
|
$where = $matches[1];
|
||||||
$numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE $where");
|
$numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE $where");
|
||||||
$max_page = ceil($numposts / $posts_per_page);
|
$max_page = ceil($numposts / $posts_per_page);
|
||||||
|
|
Loading…
Reference in New Issue