Month abbreviation in Wordpress Archives Widget
I've been trying for 3 straight days with no luck to make the 开发者_如何学Goarchives widget display the months in their abbreviated form that are included in locale.php So far I'm down to this piece of code where the month names originate in general-template.php:
if ( $arcresults ) {
$afterafter = $after;
foreach ( (array) $arcresults as $arcresult ) {
$url = get_month_link( $arcresult->year, $arcresult->month );
/* translators: 1: month name, 2: 4-digit year */
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
if ( $show_post_count )
$after = ' ('.$arcresult->posts.')' . $afterafter;
$output .= get_archives_link($url, $text, $format, $before, $after);
}
I did find in the same file where the calendar widget originates the abbreviated months. But with my limited knowledge I haven't been able to adapt it to the archives:
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>';
}
Can anyone please give me some tips or help me use the get_month_abbrev function to work in the archives?
Thanks in advance!
Ok. So a friend helped me crack this.
Go into general-template.php and
replace:
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
with:
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month_abbrev($wp_locale->get_month($arcresult->month)), $arcresult->year);
Thanks everyone.. Hope it helps more people out there.
(in Wordpress 3.5.1, the filepath is: 'wordpress\wp-includes\general-template.php' and this string is on line 937)
精彩评论