【问题标题】:WordPress "wp_list_comments" custom orderWordPress“wp_list_comments”自定义订单
【发布时间】:2010-11-21 20:15:49
【问题描述】:

我正在使用 WordPress 3.0.1 并希望使用评级自定义字段从帖子中订购 cmets。

这可能吗?我已经在使用 wp_list_cmets 的回调属性来自定义 cmets 的外观。

可惜这样我只能逐个访问cmets,不能影响所有结果数组的顺序。

我已经有一张表格,里面有所有用户的投票。

提前致谢。

【问题讨论】:

    标签: php wordpress


    【解决方案1】:
    // 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);
    

    【讨论】:

      【解决方案2】:

      试试$comments = get_comments('postId=x');。它应该由评论 id 索引。然后,您可以在表格中查找评论评分。

      【讨论】:

        猜你喜欢
        • 2021-08-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-05
        • 1970-01-01
        相关资源
        最近更新 更多