欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

wordpress主題評(píng)論中添加回復(fù)的方法

  發(fā)布時(shí)間:2014-12-20 15:10:37   作者:佚名   我要評(píng)論
這篇文章主要為大家介紹了wordpress主題評(píng)論中添加回復(fù)的方法,可以無(wú)需通過(guò)插件來(lái)實(shí)現(xiàn)增加評(píng)論回復(fù)功能,是非常實(shí)用的技巧,需要的朋友可以參考下

本文實(shí)例講述了wordpress主題評(píng)論中添加回復(fù)的方法。分享給大家供大家參考。具體如下:

很多朋友要給自己主題評(píng)論加個(gè)@reply回復(fù)效果,都會(huì)選擇用插件,其實(shí)我們可以完全修改源碼來(lái)實(shí)現(xiàn),這里就來(lái)給大家介紹wordpress主題評(píng)論中怎么添加@reply回復(fù).

方法如下:

一、在評(píng)論頁(yè)comments.php添加如下JS代碼:

復(fù)制代碼
代碼如下:
<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中加入如下代碼

復(fù)制代碼
代碼如下:
//@reply回復(fù)功能
function to_reply() {
?>
<a onclick='to_reply("<?php comment_ID() ?>", "<?php comment_author();?>")' href="#respond" style="cursor:pointer;"/>[@reply]</a>
<?php
}
?>

三、在評(píng)論頁(yè)
復(fù)制代碼
代碼如下:
<?php comment_author_link() ?>
后邊添加”回復(fù)按鈕”,代碼如下:

復(fù)制代碼
代碼如下:
<strong><?php to_reply(); ?></strong>

希望本文所述對(duì)大家的WordPress建站有所幫助。

相關(guān)文章

最新評(píng)論