最近访客
uuu1354134的头像-狐狸库
uuu1354134
百度未收录

WordPress评论如何添加@reply功能

WordPress评论如何添加@reply功能-狐狸库
wordpress

一、WordPress的评论页comments.php添加如下JS代码:

<script language=\"javascript\">
//<![CDATA[
function to_reply(commentID,author) {
var nNd=\'@\'+author+\':\';
var myField;
if (document.getElementById(\'comment\') && document.getElementById(\'comment\').type == \'textarea\') {
myField = document.getElementById(\'comment\');
} else {
return false;
}
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = nNd;
myField.focus();
}
else if (myField.selectionStart || myField.selectionStart == \'0\') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
var cursorPos = endPos;
myField.value = myField.value.substring(0, startPos)
+ nNd
+ myField.value.substring(endPos, myField.value.length);
cursorPos += nNd.length;
myField.focus();
myField.selectionStart = cursorPos;
myField.selectionEnd = cursorPos;
}
else {
myField.value += nNd;
myField.focus();
}
}
//]]>
</script>

二、在functions.php中加入如下代码:

function to_reply() {
?>
<a onclick=\'to_reply(\"<?php comment_ID() ?>\", \"<?php comment_author();?>\")\' href=\"#respond\" style=\"cursor:pointer;\"/>[@reply]</a>
<?php
}

三、在评论页后边添加”回复按钮”

<?php to_reply(); ?>
温馨提示: 本文最后更新于2022/10/20 03:35:12。若文章内容或图片失效,请 留言联系站长反馈!
!
也想出现在这里? 联系我们
创意广告
© 版权声明
THE END
点赞0赞赏 分享
评论 抢沙发

请登录后发表评论

    请登录后查看评论内容