一、在主题functions.php文件中添加如下代码:
二、在主题comments.php的评论列表处添加如下代码:
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/at-reply-ylife.js"></script>
其中at-reply-ylife.js文件内容如下:
/*reply*/ function at_reply(commentID,author) { var nNd='<a href="#comment-'+commentID+'">'+'@'+author.replace(/\t|\n|\r\n/g, "")+' </a>'+'\n'; 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(); } }
三、在需要显示回复按钮的地方用如下代码调用:
<?php at_reply(); ?>