Wordpress Archives Widget 中的月份缩写
我已经连续 3 天尝试,但没有运气让档案小部件以缩写形式显示 locale.php 中包含的月份 到目前为止,我已经了解了这段代码,其中月份名称源自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);
}
我确实在日历小部件源自缩写月份的同一个文件中找到了。但由于我的知识有限,我无法将其适应档案:
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>';
}
任何人都可以给我一些提示或帮助我使用 get_month_abbrev 函数在档案中工作吗?
提前致谢!
I've been trying for 3 straight days with no luck to make the archives 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。所以一个朋友帮我解决了这个问题。
进入general-template.php并将
:替换
为:
谢谢大家..希望它可以帮助更多的人。
(在 WordPress 3.5.1 中,文件路径为:'wordpress\wp-includes\general-template.php',该字符串位于第 937 行)
Ok. So a friend helped me crack this.
Go into general-template.php and
replace:
with:
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)