本文实例讲述了wordpress主题评论中增加回复的办法。分享给大家供大家参考。详细如下:
很多冤家要给本人主题评论加个@reply回复成果,都会抉择用插件,其实咱们能够齐全修正源码来完成,这里就来给大家引见wordpress主题评论中怎样增加@reply回复.
办法如下:
一、在评论页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>
//@reply回复性能
function to_reply() {
?>
<a onclick='to_reply("<?php comment_ID() ?>", "<?php comment_author();?>")' href="#respond" style="cursor:pointer;"/>[@reply]</a>
<?php
}
?>
<?php comment_author_link() ?>
后边增加”回复按钮”,代码如下:<strong><?php to_reply(); ?></strong>
心愿本文所述对大家的WordPress建站有所协助。
以上就是安达网络工作室关于《wordpress主题评论中添加回复的方法》的一些看法。更多内容请查看本栏目更多内容!
普通人们应用WordPress的Cron API来完成定时义务,它的原理就是将创立的定时义务存储到数据库里,当有人拜访...
明天忽然有个网友留言说博客的Feed挂了,症状如下: Chrome间接关上订阅页面显示如下: This page contain...
在装置wordpress的时分,依照外面的readme.html的步骤进行装置,然而在拜访wp-admin/install.php的时分就呈...
家喻户晓,wordpress是基于php开发,在apache效劳下运转是最优秀的。然而,国际依然有很多主机上不能提供ap...
本文实例讲述了Wordpress将选中内容分享到新浪腾讯微博的办法。分享给大家供大家参考。详细办法如下: 1、引...
在主题的function.php文件中,能够找到形如如下内容的语句:复制代码代码如下:if ( function_exists(&lsquo...