wp_list_comments函数并说文本wordpress

时间:2013-09-02 10:07:52

标签: wordpress

在评论作者姓名输出wp_list_comments后,如何更改文本 WordPress中的功能?
默认值是“说:”但我只需要插入我的文本。我用CSS做了这个并且显示:none。但它看起来不太好看

2 个答案:

答案 0 :(得分:0)

您可以删除或更改评论列表中的“说”,将以下类和函数添加到主题函数中.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
         }  
        }
}

答案 1 :(得分: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);