mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
fixed posts_nav_link again, to reclaim functionality lost in last fix ;)
git-svn-id: http://svn.automattic.com/wordpress/trunk@1784 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fc528e3d09
commit
f1cd47763b
@ -545,12 +545,40 @@ 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 »') {
|
||||
global $posts_per_page, $wpdb;
|
||||
global $request, $posts_per_page, $wpdb;
|
||||
if (! is_single()) {
|
||||
|
||||
if (get_query_var('what_to_show') == 'posts') {
|
||||
$numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_date_gmt <= '".gmdate('Y-m-d H:i:s')."' AND post_status = 'publish'");
|
||||
preg_match('#WHERE 1=1 AND (.*)GROUP BY#', $request, $matches);
|
||||
$where = $matches[1];
|
||||
$numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE $where");
|
||||
$max_page = ceil($numposts / $posts_per_page);
|
||||
} else {
|
||||
$max_page = 999999;
|
||||
|
Loading…
Reference in New Issue
Block a user