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

所属分类: CMS教程 / WordPress 阅读数: 893
收藏 0 赞 0 分享

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

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

更多精彩内容其他人还在看

WordPress 网站如何防范大规模暴力破解攻击

本文主要讲述了WordPress 网站如何防范大规模暴力破解攻击,有兴趣的朋友一起来看看吧
收藏 0 赞 0 分享

WordPress 4.1 发布:开启免干扰写作模式

WordPress 4.1 正式版发布,这次更新带来了2015主题(Twenty Fifteen),免干扰写作模式,隐藏各种杂乱以及干扰选项,让博主全身心灌注于文章写作。
收藏 0 赞 0 分享

WordPress分类与标签等存档页实现置顶的方法

这篇文章主要为大家介绍了WordPress分类与标签等存档页实现置顶的方法,通过二次开发实现存档页的置顶功能,是非常实用的技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

WordPress后台显示相关用户文章相关联评论的方法

这篇文章主要为大家介绍了WordPress后台显示相关用户文章相关联评论的方法,通过增加自定义函数SQL调用来实现显示相关评论的功能,非常具有实用价值,需要的朋友可以参考下
收藏 0 赞 0 分享

WordPress自动给文章添加nofollow属性的实现方法

这篇文章主要为大家介绍了WordPress自动给文章添加nofollow属性的实现方法,可通过Nofollow for external link 插件实现文章页自动添加nofollow属性的功能,是非常实用的技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

WordPress快速添加友情链接功能的方法

这篇文章主要为大家介绍了WordPress快速添加友情链接功能的方法,通过自定义函数实现后台友情链接功能,是WordPress二次开发的典型应用,需要的朋友可以参考下
收藏 0 赞 0 分享

多备份:一键自动备份你的WordPress博客

数据备份是博客的头等大事,尤其是当你数据丢失或者网站被黑的时候,你会更加强烈的感觉到。
收藏 0 赞 0 分享

WordPress使用RSS Feed输出自定义文章类型内容的方法

这篇文章主要为大家介绍了WordPress使用RSS Feed输出自定义文章类型内容的方法,可通过简单的自定义函数实现这一功能,非常具有实用价值,需要的朋友可以参考下
收藏 0 赞 0 分享

WordPress实现搜索结果包括自定义文章类型内容的方法

这篇文章主要为大家介绍了WordPress实现搜索结果包括自定义文章类型内容的方法,通过自定义函数的设置来实现WordPress搜索结果包括自定义文章类型,是非常实用的技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

Wordpress自动将包含长链接的评论标记为垃圾评论的方法

这篇文章主要为大家介绍了Wordpress自动将包含长链接的评论标记为垃圾评论的方法,介绍了常用的几种经典方法,具有一定的参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多