QQ咨询不加好友发不了信息,咨询前先加好友! → QQ:820896380

WordPress评论如何添加@reply功能

wordpress 一、WordPress的评论页comments.php添加如下JS代码: <script language="javascript"> //<![CDATA[ function to_reply(commentID,author) { var nNd='@'+a...
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(); ?>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
wordpress教程

如何给WordPress新建一个登录页面

2023-2-16 23:45:33

wordpress教程

WordPress 经典编辑器快捷键(老版本)

2023-2-16 23:45:35

!
你也想出现在这里?立即 联系我们吧!
信息
个人中心
购物车
优惠劵
有新私信 私信列表
搜索