• Resolved dejman

    (@dejman)


    This plugin does all I want except that I really need to display the comment randomly. Any help please?

    Even if I need to edit some codes. Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi dejman,

    FYI, the comments are fetched from the db with a query which includes the usual query parameters including one for ordering how they are fetched.

    IMHO you should also check the plugin API and especially the Filter hook the_comments found here: https://docs.itthinx.com/document/decent-comments/api/

    Perhaps this way you can randomize the array of comments the way you prefer. Even though I haven’t tried it myself, in theory it should be possible.

    Kind regards,
    George

    Plugin Author itthinx

    (@itthinx)

    There is in fact a filter that can be used for this – although you should be aware of the performance implications of a randomized query on a large amount of comments.

    The filter is the_comments and it receives two bits in an array passed to it, the $comments and the Decent_Comments object that retrieves the comments. You can replace the $comments with those that you want, e.g. randomized ones.

    This is where the filter is applied: https://github.com/itthinx/decent-comments/blob/master/class-decent-comment.php#L300

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Order comments randomly’ is closed to new replies.