Ticket #966: patch
| File patch, 2.1 KB (added by excalin, 7 years ago) |
|---|
-
template-functions-links.php
485 485 } 486 486 } 487 487 488 function count_pages($what_to_count) { 489 global $request, $posts_per_page, $wpdb; 490 491 preg_match('#FROM (.*) GROUP BY#', $request, $matches); 492 $fromwhere = $matches[1]; 493 $fromwhere = preg_replace("(/\*TAG\*/.*/\*TAG\*/)","",$fromwhere); 494 $numposts = $wpdb->get_var("SELECT COUNT($what_to_count) FROM $fromwhere"); 495 return (ceil($numposts / $posts_per_page)); 496 } 497 488 498 function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') { 489 global $request, $posts_per_page, $wpdb;490 499 if (! is_single()) { 500 switch (get_query_var('what_to_show')) { 501 case 'posts': 502 $max_page = count_pages('ID'); 503 break; 491 504 492 if (get_query_var('what_to_show') == 'posts') { 493 preg_match('#FROM (.*) GROUP BY#', $request, $matches); 494 $fromwhere = $matches[1]; 495 $numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere"); 496 $max_page = ceil($numposts / $posts_per_page); 497 } else { 505 case 'days': 506 $max_page = count_pages('DISTINCT DATE_FORMAT(post_date, \'%d %m %Y\')'); 507 break; 508 509 default: 498 510 $max_page = 999999; 499 }511 } 500 512 501 513 if ($max_page > 1) { 502 514 previous_posts_link($prelabel); -
classes.php
525 525 $end_date = $wpdb->get_var("SELECT min(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $endrow,1"); 526 526 527 527 if ($page > 1) { 528 $where .= " AND post_date >= '$end_date' AND post_date <= '$start_date'";528 $where .= " /*TAG*/ AND post_date >= '$end_date' AND post_date <= '$start_date' /*TAG*/"; 529 529 } else { 530 $where .= " AND post_date >= '$end_date'";530 $where .= " /*TAG*/ AND post_date >= '$end_date' /*TAG*/"; 531 531 } 532 532 } 533 533 }
