让WordPress调取指定分类下的评论
由于某种特殊的需要,有的时候需要让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》《?phpif ($i 》= $real_comments) break;
}
?》
使用时请将“《”和“》”改成“<”和“>”
声明:原创博客,转载请注明 吓我一跳



先收藏,以后肯定用的着
呵呵,等博客日IP10000以上就用得到了,中秋快乐!
What is your favorite sport? ,
The answer that immediately leapt to mind was The Matrix.
quality, standards-based
Are you saying I’m only here for the emo? ,