This function will list all posts, and group them by day. If you want to use it – add it to your my-hacks.php file. (See more information on how to use my-hacks.php here – link via Carthik)
Again – I made this function specifically for a personal use – so there's not a lot of 'easy customization' without specifically editing the code, so I apologize for the lack of ease-of-use – but I wanted to post this for my own "code storage".
Here's the function:
function displayAllPostsGrouped () {
global $wpdb, $tableposts;
$now = current_time('mysql');
$previousPostDate = ";
$firstrun = true;
$arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC");
if ($arcresults) {
foreach ($arcresults as $arcresult) {
if ($arcresult->post_date != '0000-00-00 00:00:00') {
$url = get_permalink($arcresult->ID);
$arc_title = stripslashes($arcresult->post_title);
if ($arc_title) {
$text = strip_tags($arc_title);
} else {
$text = $arcresult->ID;
}
$post_date = substr($arcresult->post_date, 0, 10);
$post_day = substr($arcresult->post_date, 8, 2);
$post_year = substr($arcresult->post_date, 0, 4);
$post_month = substr($arcresult->post_date, 5, 2);
if ($previousPostDate != $post_date) {
if (!$firstrun) {
echo "</p>";
}
echo "<p><b>".$post_month.".".$post_day.".".$post_year."</b><br />";
}
echo "<a href='".$url."'>".$text."</a><br />";
$previousPostDate = $post_date;
}
}
}
}
Post last updated: 6/22/04 9:18pm