[wp-hackers] Hacking Assignment: Paging by Days
Sebastian Herp
newsletter at scytheman.net
Mon Sep 6 14:16:33 UTC 2004
As much as i hate replying to myself, there was something wrong with the
code ...
Insert this in the "} elseif ($q['what_to_show'] == 'days') {"-case and
it will work (this time tested):
$startrow = $q['posts_per_page'] *
(intval($page)-1);
$start_date = $wpdb->get_var("SELECT
max(post_date) FROM $wpdb->posts
GROUP BY year(post_date),
month(post_date), dayofmonth(post_date)
ORDER BY post_date DESC
LIMIT $startrow,1");
$endrow = $startrow +
$q['posts_per_page'] - 1;
$end_date = $wpdb->get_var("SELECT
min(post_date) FROM $wpdb->posts
GROUP BY year(post_date),
month(post_date), dayofmonth(post_date)
ORDER BY post_date DESC
LIMIT $endrow,1");
if ($page > 1) {
$where .= " AND post_date >=
'$end_date' AND post_date <= '$start_date'";
} else {
$where .= " AND post_date >=
'$end_date'";
}
Adds another query, but is sexy as hell :-)
One thing though: this is the first time i tried out the cvs version.
While i can't say it is slow, i noticed that it takes 41 queries to
build up the mainpage compare to around 10 queries on a stock wordpress
1.2. Why? This would slow down websites where the mysqlserver is not the
the webserver, too ...
Greetings,
Sebastian
Sebastian Herp wrote:
> You realize that this is sloooooowwwww as hell?
.....
More information about the hackers
mailing list