Updated: New plugin based on these code snippets.
I think if I can know what I wrote in one year ago, then I may be able to write another post after one year. So I wrote these simple code. The first one is used in main posts loop, you might want to use is_single() for checking whether is in single post mode.
$onthisday = $wpdb->get_results("SELECT ID, post_title, post_date FROM $wpdb->posts WHERE post_status= \"publish\" AND post_type=\"post\" AND post_date_gmtID ORDER BY post_date DESC LIMIT 5");
$oldPost = $post;
if(sizeof($onthisday)>0)
foreach($onthisday as $post)
echo get_the_time("Y") . ': ID) . '">' . the_title('','',FALSE) . '
';
else
echo "No other post on this day.";
$post = $oldPost;
First line, retreive posts which have been published before current time, and posts’ publishing month and day are the same as current viewing post’s. For each post, prints the year, then the post’s title and link.
Next code snippet is similar to first one. It should be used as showing posts whose publishing month and day are the same as current month and day. In order to match time zone offset, we need to get gmt_offset from WordPress and use the offset to query from wp_posts.
$time = time() + (get_option('gmt_offset') * 3600);
$onthisday = $wpdb->get_results("SELECT ID, post_title, post_date FROM $wpdb->posts WHERE post_status= \"publish\" AND post_type=\"post\" AND post_date_gmt 0)
foreach($onthisday as $post)
echo get_the_time("Y") . ': ID) . '">' . the_title('','',FALSE) . '
';
else
echo "No other post on this day.";
$post = $oldPost;
Please copy the source here. You can see the result below this line.