本文实例讲述了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主题评论中添加回复的方法》的一些看法。更多内容请查看本栏目更多内容!
登陆函数:wp_signon() 函数引见: wp_signon()函数用于受权给用户登陆wordpress并可记住该用户称号。该函数...
建设多言语切换的网站有两种形式,一种是子域名方式,另一种则是子目录方式。而以这两种方式建站,中文站点...
本文实例讲述了获取wordpress注册用户的数量的办法分享给大家供大家参考。详细完成办法如下: 办法一,代码如...
家喻户晓,wordpress是基于php开发,在apache效劳下运转是最优秀的。然而,国际依然有很多主机上不能提供ap...
招致wordpress页面呈现空白框的缘由大略有两点: 一,UTF-8即文件保留类型 文件保留类型与应用版本之间假如...
本文实例讲述了在wordpress截取首页摘要内容完成办法,分享给大家供大家参考。详细剖析如下: 这里截取就是利...