Ticket #739: 739.diff
| File 739.diff, 2.8 KB (added by westi, 6 years ago) |
|---|
-
wp-includes/query.php
868 868 $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', '; 869 869 $limits = 'LIMIT '.$pgstrt.$q['posts_per_page']; 870 870 } elseif ($q['what_to_show'] == 'days') { 871 $startrow = $q['posts_per_page'] * (intval($page)-1);872 $start_date = $wpdb->get_var("SELECT max(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 $startrow,1");873 $endrow = $startrow + $q['posts_per_page'] - 1;874 $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");871 // $startrow = $q['posts_per_page'] * (intval($page)-1); 872 // $start_date = $wpdb->get_var("SELECT max(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 $startrow,1"); 873 // $endrow = $startrow + $q['posts_per_page'] - 1; 874 // $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"); 875 875 876 $start_days = $q['posts_per_page'] * (intval($page)-1); 877 $end_days = $start_days + $q['posts_per_page'] -1; 876 878 if ($page > 1) { 877 $where .= " AND post_date >= '$end_date' AND post_date <= '$start_date'";879 $where .= " AND post_date >= DATE_SUB(NOW(), INTERVAL '$end_days' DAY) AND post_date <= DATE_SUB(NOW(), INTERVAL '$start_days' DAY)"; 878 880 } else { 879 $where .= " AND post_date >= '$end_date'";881 $where .= " AND post_date >= DATE_SUB(NOW(), INTERVAL '$end_days' DAY)"; 880 882 } 881 883 } 882 884 } -
wp-includes/template-functions-links.php
477 477 } else { 478 478 $posts = $wp_query->posts; 479 479 preg_match('#WHERE\s(.*)\sGROUP BY#siU', $wp_query->request, $matches); 480 $where = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]); 480 //$where = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]); 481 $where = preg_replace('/( AND )?post_date >= (.*?)( AND post_date <= (.*?))?/siU', '', $matches[1]); 481 482 $num_days = $wpdb->query("SELECT DISTINCT post_date FROM $wpdb->posts WHERE $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date)"); 482 483 return ceil($num_days / get_option('posts_per_page')); 483 484 }
