退房一般的template.php。兩個函數wp_get_archives和get_archives_link。您必須破解wp_get_archives才能更改在$ text中加載的內容。帖子數被加載到放置在get_archives_link鏈接之外的$ after變量中。取而代之的是:
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
if ($show_post_count)
$after = ' ('.$arcresult->posts.')' . $afterafter;
是這樣的:
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
if ($show_post_count)
$text= $text.' <small>'.$arcresult->posts.'</small>';
這還只是每月存檔。您必須對每年,每週和每日塊進行修改。
編輯:排除來自鏈接的標題<small>
元件最簡單方法是加載它在每個塊中一個單獨的變量,然後將其通入經修飾的get_archives_link。在上面的例子中,右後$文本被載入了剛剛加載值到$標題:
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
$title = $text;
if ($show_post_count)
$text= $text.' <small>'.$arcresult->posts.'</small>';
$output .= get_archives_link($url, $text, $format, $before, $after, $title);
然後修改get_archives_link:
function get_archives_link($url, $text, $format = 'html', $before = '', $after = '', $title = '') {
$text = wptexturize($text);
if($title == '')
$title = $text;
$title_text = esc_attr($title);
$url = esc_url($url);
if ('link' == $format)
$link_html = "\t<link rel='archives' title='$title_text' href='$url' />\n";
elseif ('option' == $format)
$link_html = "\t<option value='$url'>$before $text $after</option>\n";
elseif ('html' == $format)
$link_html = "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";
else // custom
$link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";
$link_html = apply_filters("get_archives_link", $link_html);
return $link_html;
}
優秀的東西安德魯,運作良好。然而,我只有一個問題。 標籤在標題屬性中包含標籤。換句話說,如果我把光標放在(鏈接)上,我不僅會得到相關信息,比如2011年2月 - 6篇文章,還有標籤會讓事情變得糟糕:「2011年2月 - 6篇文章'。如何刪除的title =「」屬性中提及的標籤? – Sotkra 2011-02-17 04:04:40