WordPress 主題教程之修改 WordPress 回覆評論文字方法,首選需要建立個自定義的評論模板,然後透過呼叫此評論函式來實現自定義。透過以下程式碼可以實現修改回覆文字:

<?php
$defaults = array('add_below' => 'comment', 'respond_id' => 'respond', 'reply_text' => __('Reply'),
'login_text' => __('Reply'), 'depth' => 0, 'before' => '', 'after' => '');
comment_reply_link(array_merge( $defaults, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>

你可以將 Reply 修改成你希望的文字。

$defaults = array(『add_below』 => 『comment』, 『respond_id』 => 『respond』, 『reply_text』 => __(『Reply』), 這行是預設的回覆評論。
『login_text』 => __(『Reply』), 『depth』 => 0, 『before』 => 」, 『after』 => 」); 這行是登陸後評論。
comment_reply_link(array_merge( $defaults, array(『depth』 => $depth, 『max_depth』 => $args['max_depth']))) 這行是評論連結。

將以上程式碼放在評論 loop 內既可使用,下面是完整的 custom_comment.php 函式檔案:

<?php
if (!function_exists("custom_comment")) {
function custom_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?>>
<a name="comment-<?php comment_ID() ?>"></a>
<?php if(get_comment_type() == "comment"){ ?>
<?php the_commenter_avatar($args) ?>
<?php } ?>
<?php
$defaults = array('add_below' => 'comment', 'respond_id' => 'respond', 'reply_text' => __('Reply'),
'login_text' => __('Reply'), 'depth' => 0, 'before' => '', 'after' => '');
comment_reply_link(array_merge( $defaults, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
<?php the_commenter_link() ?>
<?php
echo get_comment_date(get_option( 'date_format' )) ?> <?php
_e('at', 'jintu'); ?> <?php echo get_comment_time(get_option(
'time_format' )); ?>
<?php edit_comment_link(__('Edit', 'jintu'), '', ''); ?>
<?php comment_text() ?>
<?php if ($comment->comment_approved == '0') { ?>
<p ><?php _e('Your comment is awaiting moderation.', 'jintu'); ?></p>
<?php } ?>
<?php
}
} ?>

將上面的程式碼儲存到 custom_comment.php 檔案,在 functions.php 裡載入即可,WordPress 修改回覆文字的方法就這麼簡單,試試吧。