I would like my posts on the front page to be organized per day (like issues of a magazine). I came up with the code below.
It works on the first page of the front page, it only shows posts from the last issue (last day that posts were posted). If I click on 'older entries' things start getting to go wrong.
The post-limit of the first page (day/issue) is used, instead of the limit of the page (day/issue) shown. That's because I base the date on '$posts[0]->post_date', which is the first post in the posts object. That object holds always all latest posts, also on front pages two and beyond.
To fix my problem I need a way to determine the array-number of the post with which the frontpages 2 and beyond starts their loop, so I can use that to get the date of the proper post. Like '$posts[18]->post_date' for example, where '18' is the array number.
<?php // change post limit to show posts of only one day
if (is_front_page()) {
//get date of first post
$cpd=mysql2date('Ymd', $posts[0]->post_date);
//get all posts from that date
$posts_of_day=get_posts('year=' .substr($cpd, 0, 4) .'&monthnum=' .substr($cpd, 4, 2) .'&day=' .substr($cpd, 6, 2).'&showposts=1000');
//Count the amount of posts of that date
$daylimit=count($posts_of_day);
//limit the amount of posts that are shown accordingly
query_posts($query_string . "&showposts=".$daylimit);
} ?>