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>
//<![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
}
?>
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)文章
- 在瀏覽網(wǎng)頁(yè)的時(shí)候, 我們經(jīng)常會(huì)看到很多人在他們網(wǎng)站的搜索欄里顯示文字提示, 當(dāng)鼠標(biāo)點(diǎn)擊搜索欄, 則提示信息消失.2011-05-10
- 本文詳介如何給WordPress投稿功能添加郵件提醒功能2012-09-28
為WordPress添加文章字?jǐn)?shù)統(tǒng)計(jì)的方法
下面看一下如何統(tǒng)計(jì)文章字?jǐn)?shù)2012-10-06WordPress中添加語(yǔ)音搜索功能的實(shí)現(xiàn)方法
這篇文章主要為大家介紹了WordPress中添加語(yǔ)音搜索功能的實(shí)現(xiàn)方法,屬于html5 的speech功能的API,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2014-12-18- 這篇文章主要為大家介紹了WordPress添加前臺(tái)注冊(cè)功能的方法,較為詳細(xì)的分析了前臺(tái)注冊(cè)功能的完整實(shí)現(xiàn)過(guò)程,是進(jìn)行WordPress開發(fā)非常實(shí)用的技巧,需要的朋友可以參考下2014-12-17
wordpress編輯器中添加鏈接功能自動(dòng)加入nofollow的方法
這篇文章主要介紹了wordpress編輯器中添加鏈接功能自動(dòng)加入nofollow的方法,需要的朋友可以參考下2014-04-10在wordpress文章末尾添加內(nèi)容的簡(jiǎn)單方法
如何在wordpress的文章末尾添加內(nèi)容,在wordpress每篇文章的末尾添加文字、鏈接等內(nèi)容,比如你想加個(gè)“原創(chuàng)文章如轉(zhuǎn)載,請(qǐng)注明本文鏈接:”,其實(shí)很簡(jiǎn)單,有多種方法,下面2013-11-13wordpress后臺(tái)中的側(cè)邊欄添加菜單或子菜單的方法
在后臺(tái)中的側(cè)邊欄添加菜單或子菜單。比如向已經(jīng)存在的菜單中添加子菜單等等,具體的實(shí)現(xiàn)如下,感興趣的朋友可以參考下2013-09-02wordpress后臺(tái)添加子菜單的常用幾種情況及對(duì)應(yīng)方法
添加子菜單比如在文章處添加子菜單、在鏈接處添加子菜單、在頁(yè)面處添加子菜單等等,本文列舉了常用的幾種情況及對(duì)應(yīng)的函數(shù),感興趣的朋友可以參考下,希望可以幫助到大家2013-09-02- 現(xiàn)在二維碼很火呀,微信掃碼很火呀,為自己的博客每天文章都添加一個(gè)二維碼功能豈不是很牛X呀2013-08-22