在 WordPress 中 wp_list_comments 函数的输出中出现评论作者姓名后,如何更改文本?
默认值为“说:”但我只需要在其中插入我的文本。我已经用 CSS 和 display:none 做到了。但它看起来不太好
问问题
1277 次
2 回答
0
您可以从评论列表中删除或更改“说”,将以下类和函数添加到您的主题 functions.php
class Comment_Says_Custom_Text_Wrangler {
function comment_says_text($translation, $text, $domain) {
$new_says = ''; //whatever you want to have instead of 'says' in comments
$translations = &get_translations_for_domain( $domain );
if ( $text == '<cite class="fn">%s</cite> <span class="says">says:</span>' ) {
if($new_says) $new_says = ' '.$new_says; //compensate for the space character
return $translations->translate( '<cite class="fn">%s</cite><span class="says">'.$new_says.':</span>' );
} else {
return $translation; // standard text
}
}
}
于 2013-09-02T11:26:52.217 回答
0
代码add_filter('gettext', array('Comment_Says_Custom_Text_Wrangler', 'comment_says_text'), 10, 4);
应添加到代码中:
class Comment_Says_Custom_Text_Wrangler {
function comment_says_text($translation, $text, $domain) {
$new_says = ''; //whatever you want to have instead of 'says' in comments
$translations = &get_translations_for_domain( $domain );
if ( $text == '<cite class="fn">%s</cite> <span class="says">says:</span>' ) {
if($new_says) $new_says = ' '.$new_says; //compensate for the space character
return $translations->translate( '<cite class="fn">%s</cite><span class="says">'.$new_says.':</span>' );
} else {
return $translation; // standard text
}
}
}
add_filter('gettext', array('Comment_Says_Custom_Text_Wrangler', 'comment_says_text'), 10, 4);
于 2015-04-03T07:57:49.157 回答