wp-thread-comment插件改进用法,评论、回复总数显示(原创)

以下为原创笨教程,需要转载只要注明就OK了,囧rz…
相信用WP做BLOG的人都用过wordpress-thread-comment这个插件吧?很强大的一个插件,但是美中不足的是在发表评论时,他没有做到更新评论总条数或者统计评论中属于回复的评论的总数的功能。

示意图:

要实现这项功能有什么办法呢?(我不知道有没别的插件更好,囧RZ有的话告诉我一下)其实不难,只要你会WP建立页面时的那个调用模板就OK了!要改动的文件只有3个,一个是wordpress-thread-comment插件目录下的wp-thread-comment.js.php,wp-thread-comment.php和自己主题风格中的comments.php文件,注意:这里用了模板的话就不是他了,页面自定义调用模板的方法,不懂可以留言,我虽然也是WP新手但是很乐意给你回答。好言归正卷,首先我们改的是comments.php文件,通常没修改过的情况下在开头的前几行会发现一下代码:

1
2
3
4
5
6
<h2 id="comments">
<?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments')); ?>
<?php if ( comments_open() ) : ?>
<a href="#postcomment" title="<?php _e("Leave a comment"); ?>">&raquo;</a>
<?php endif; ?>
</h2>

我们把他改为

1
2
3
4
5
6
7
8
9
10
11
12
<h2 id="comments">
<?php if ( $comments ){
 echo '<span id="mnum">'.count($comments).'</span>留言主题';
 global $id;
 echo '(含<span id="rnum">'.(get_comments_number($id)-count($comments)).'</span>回复)';
 }
 else echo '没有留言主题'
 ?>
<?php if ( comments_open() ) : ?>
	<a href="#postcomment" title="<?php _e("发表留言"); ?>">&raquo;</a>
<?php endif; ?>
</h2>

当然这里要是你要求是评论页的而不是留言页的,你就适当修改为需要的。

15 Responses to wp-thread-comment插件改进用法,评论、... »

  1. cHunge 评论 2008-08-16 17:30

    枫林驿,链接已加。加油哦~

    回复

    joe 回复 八月 16th, 2008 at 19:08

    :wink: OK! Eyes on you.

    回复

  2. a691662 评论 2008-08-18 08:40

    很好

    回复

  3. nwgale 评论 2008-08-27 23:02

    绝了绝了,我今天从下午一直到现在,都在琢磨这个插件,被逼得没办法,去WP论坛上一搜就找到你这儿来了,早知道直接来你这里看了,呵呵

    回复

  4. 禅猫 评论 2008-09-14 01:30

    :cool: 你好,我想请问下,此插件默认设置的回复背景色在wp-thread-comment.php里是否可以更改,在地几行,因为我不想调用插件自带的CSS编辑…感谢!

    回复

    joe 回复 九月 14th, 2008 at 01:43

    你意思是:你想更改主题下的css来更改他的样式?

    回复

    joe 回复 九月 14th, 2008 at 01:44

    可以的!

    回复

    joe 回复 九月 14th, 2008 at 03:59

    不过不是修改wp-thread-comment.php而是修改wp-thread-comment.js.php的310行左右wptctextreplace($s(‘newcomment’),rs)
    这里的rs你那里可能不一样
    这行下面增加一下代码:
    var tmp=document.createElement(“div”);
    tmp.innerHTML=rs;//这里rs要跟上面那个一样 $(tmp.firstChild.id).style.cssText=”background:red”;

    回复

  5. rodney 评论 2008-09-20 00:55

    我遇到了更麻烦的问题 。。。 :shock:
    给我看看啊,,, :cry:
    我的“回复”简直就是摆设 。。。。 :neutral:
    帮忙咯 。。。
    谢谢 :wink: :wink:

    回复

    joe 回复 九月 20th, 2008 at 01:52

    你回复插件的问题,文件不在我不能调试,很难知道哪里出了问题,估计是文件不完整或者插件冲突造成的。尝试下载一个别的下载地址的试下。要是还不行就在wp-thread-comment.js.php这个文件的310行左右找到
    var tmp=document.createElement(“div”);
    这一句在它上面加以下语句,
    alert(req.responseText);
    保存,然后尝试回复,看提示什么,把内容发我看

    回复

  6. 調調 评论 2009-09-28 22:18

    试一试啦~~~~ :lol:

    回复

  7. Red42 评论 2009-10-23 00:59

    Nor do we know what social policies and norms will best facilitate fair terms of cooperation in the interactions of men and women over issues of work, career, and childrearing. ,

    回复

  8. No_limits16 评论 2009-10-23 21:57

    In general I find public schools to cater to the lowest common denominator. ,

    回复

  9. 印第安小狮 评论 2009-11-16 00:04

    :o hh: 有空再来看下吧, 今天累了, 先收藏啦, 谢谢哈,

    回复

  10. 大敏 评论 2010-03-18 17:26

    博主好强,如何做到移动的评论框,和回复框的效果!

    回复

Leave a Reply

Email address is not published

You should say a Chinese word to pass spam check. If you can not input Chinese, just copy 你好 and paste them into comment text box.