中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

怎么在wordpress主題評論中添加回復(fù)

2019-08-21    來源:愛站科技

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用

很多朋友在wordpress建站的時候都會想要給自己的主題評論加個回復(fù)效果,那么你知道怎么在wordpress主題評論中添加回復(fù)嗎?很多朋友們都互選擇用插件,其實我們只需要修改源碼即可,下面我們一起去看看吧。

方法如下:

一、在評論頁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
}
?>


三、在評論頁

?

復(fù)制代碼
代碼如下:

?

<?php comment_author_link() ?>

后邊添加”回復(fù)按鈕”,代碼如下:
?

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

?

本文中小編利用實例為大家講述了怎么在wordpress主題評論中添加回復(fù)的方法,今天在這里分享給大家供大家參考,希望本文對大家的WordPress建站有所幫助。

標(biāo)簽: wordpress主題評論 添加回復(fù)

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:教你修改WordPress評論默認(rèn)頭像

下一篇:WordPress如何屏蔽評論中的鏈接