なんか3.9.1くらいのWordPressのカレンダーって、何故か月送りのリンクが下についています。
これを、月タイトルを挟み込むような形で表示するよう書き直します。
wp-includesディレクトリ内のgeneral-template.phpをいじります。
まずは1461行目あたりから1503行目あたりにある下記コードを削除します。
/* translators: Calendar caption: 1: month name, 2: 4-digit year */ $calendar_caption = _x('%1$s %2$s', 'calendar caption'); $calendar_output = '<table id="wp-calendar"> <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption> <thead> <tr>'; $myweek = array(); for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); } foreach ( $myweek as $wd ) { $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); $wd = esc_attr($wd); $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>"; } $calendar_output .= ' </tr> </thead> <tfoot> <tr>'; if ( $previous ) { $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>'; } else { $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; } $calendar_output .= "\n\t\t".'<td class="pad"> </td>'; if ( $next ) { $calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>'; } else { $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; } $calendar_output .= ' </tr> </tfoot>
そしたら削除した場所に下記コードを貼付けます。
/* translators: Calendar caption: 1: month name, 2: 4-digit year */ $calendar_caption = _x('%1$s %2$s', 'calendar caption'); $calendar_output .= '<table id="wp-calendar"><caption>'; if ( $previous ) { $calendar_output .= "\n\t\t".'<span id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">«</a></span>'; } else { $calendar_output .= "\n\t\t".'<span id="prev" class="pad"> </span>'; } $calendar_output .= ' <span id="thismonth">'. sprintf($calendar_caption, $wp_locale->get_month($thismonth), date("Y", $unixmonth)) .'<span> '; if ( $next ) { $calendar_output .= "\n\t\t".'<span id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">»</a></span>'; } else { $calendar_output .= "\n\t\t".'<span id="next" class="pad"> </span>'; } $calendar_output .= ' </caption><thead><tr>'; $myweek = array(); for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); } foreach ( $myweek as $wd ) { $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); $wd = esc_attr($wd); $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>"; } $calendar_output .= ' </tr> </thead>'; $calendar_output .= '
あとはCSSで見てくれを整えます。
table#wp-calendar { width: 200px; } table#wp-calendar caption, table#wp-calendar thead tr th, table#wp-calendar tbody tr td { text-align: center; }