WordPress 2.9.1
functions.php に
function my_get_calendar(){
ob_start();
get_calendar();
$output = ob_get_contents();
ob_end_clean();
if(preg_match_all('@<td><a href="' . get_option('home') . '/(\?m=)?([^"]*?)" title="([^"]*?)">[0-9]+?</a>@i', $output, $matches)){
foreach($matches[0] as $key => $match){
$date = preg_replace('@/@', '', $matches[2][$key]);
$year = substr($date, 0, 4);
$month = substr($date, 4, 2);
$day = substr($date, 6, 2);
global $wpdb;
$posts = $wpdb->get_results("SELECT ID, post_title "
. "FROM $wpdb->posts "
. "WHERE YEAR(post_date) = '$year' "
. "AND MONTH(post_date) = '$month' "
. "AND DAY(post_date) = '$day' "
. "AND post_type = 'post' AND post_status = 'publish' "
. "ORDER BY post_date DESC"
);
$link = '';
foreach($posts as $post)
$link .= '<a href="'. get_permalink($post->ID) . '">' . $post->post_title . '</a>';
$output = preg_replace('@' . preg_quote($match) . '@', $match . $link, $output);
}
}
return $output;
}
カレンダーを表示したいところで
echo my_get_calendar();
スタイルは table#wp-calendar
以下の要素をお好みで指定すれば OK。