wordpress建站

WordPress回复评论文字的修改方法

2019-04-20 18:29  浏览:129

许多实用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 函数文件:

<?phpif (!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 class='unapproved'><?php _e('Your comment is awaiting moderation.', 'jintu'); ?></p><?php } ?><?php}}?>

将上面的代码保存到 custom_comment.php 文件, 在functions.php里加载即可,wordpress修改回复文字的方法就这么简单。

免责声明:
1、本站所收集的部分公开资料来源于互联网,转载的目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。
2、本站部分作品内容是由网友自主投稿和发布、编辑整理上传,对此类内容本站仅提供交流平台,不为其版权负责,更不为其观点承担任何责任。
3、因行业及专业性有限,因此不能一一验证会员发布内容的真实性及有效性,不为其负责,如有虚假或违规内容敬请举报,本站将积极配合删除。
4、如果您发现网站上有侵犯您的知识产权的作品,请与我们取得联系,我们会及时处理或删除。
发表评论
0评