wordpress主题评论中怎么添加@reply回复
发布:smiling 来源: PHP粉丝网 添加日期:2014-03-18 11:06:03 浏览: 评论:0
很多朋友要给自己主题评论加个@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>
 
二、在functions.php中加入如下代码
- //@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>
Tags: wordpress主题评论 reply回复
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
 - PHP新手上路(一)(7)
 - 惹恼程序员的十件事(5)
 - PHP邮件发送例子,已测试成功(5)
 - 致初学者:PHP比ASP优秀的七个理由(4)
 - PHP会被淘汰吗?(4)
 - PHP新手上路(四)(4)
 - 如何去学习PHP?(2)
 - 简单入门级php分页代码(2)
 - php中邮箱email 电话等格式的验证(2)
 
