让Wordpress调取指定分类下的评论6+

2009.10.03 | Tags: ,

由于某种特殊的需要,有的时候需要让Wordpress调取指定分类下的评论,比如你想让读者打开你Wordpress的一个分类页面,当这个指定的分类页面被打开之后,读者看到的评论全部全都是关于这个指定分类的评论,有利于读者更好地查阅Wordpress文章,那么如何才能让Wordpress调取指定分类下的评论呢?代码如下:

《?php
$show_comments = 10;
$i = 0;
$comments = get_comments(“number=50&status=approve”);
foreach ($comments as $comment)
{
$comm_post_id = $comment-》comment_post_ID;
if (!in_category(“blogs”, $comm_post_id))
continue;
$i++;

// “Foobar2000”是将要读取评论的分类,改成你自己的分类”
// 仅仅保留“Foobar2000”分类下的所有评论。
?》《li》《?php comment_excerpt(); ?》《/li》《?php

if ($i 》= $real_comments) break;
}
?》

使用时请将“《”和“》”改成“<”和“>”


  1. 1 万戈
    2009.10.03 / 15:26

    先收藏,以后肯定用的着

  2. 2 Yusn
    2009.10.03 / 15:37

    呵呵,等博客日IP10000以上就用得到了,中秋快乐!

  3. 3 driver14
    2009.10.23 / 05:56

    What is your favorite sport? ,

  4. 4 Barbara14
    2009.10.24 / 19:50

    The answer that immediately leapt to mind was The Matrix.

  5. 5 Settor70
    2009.10.25 / 08:43

    quality, standards-based

  6. 6 Stinky33
    2009.10.25 / 15:21

    Are you saying I’m only here for the emo? ,