2010-11-21 89 views
0

我使用的是WordPress 3.0.1,并且想要使用评级自定义字段对帖子中的评论进行排序。WordPress“wp_list_comments”自定义订单

这可能吗?我已经使用wp_list_comments中的回调属性来自定义注释的外观。

不幸的是,这种方式我只能访问评论一个接一个,不能影响所有结果数组的顺序。

我已经有了一个表格,其中包含所有来自用户的投票。

在此先感谢。

回答

0

尝试$comments = get_comments('postId=x');。它应该通过评论ID进行索引。然后,您可以查看表格中的评论评分。

0
// get comments of post 1234 
$comments = get_comments(array('post_id' => 1234)); 

// ... order your comments collection using php (eg. usort) here ... 

// print your comments 
wp_list_comments(array('callback' => 'woocommerce_comments'), $comments);