WordPress.org

Support

Support » Plugins and Hacks » Hacks » Sort comments by custom field (dropdown)

Sort comments by custom field (dropdown)

  • Hi, I’d like to use a WordPress page to enable customers to leave reviews (standard comments form with an additional custom field for user to select the product they’d like to review). They can also apply a star rating to their comment/review (using something like: Comment Rating Field Plugin). I’m fine with this part of the requirement, and would appreciate help/pointers on the following requirement:

    Add a dropdown field to enable the users to sort comments/review by products.

    Thanks,

    Al

Viewing 3 replies - 1 through 3 (of 3 total)
  • You should be able to add the dropdown html on any related template, such as comments.php or single.php.

    You can manage the comment order by hooking the ‘comments_array’ filter and sorting the array passed.

    The trick is how does your filter function know what order to use? You can capture the field change event, save or pass the setting somewhere where the filter function can get it, then sort accordingly. Or use AJAX techniques to somehow re-order the contents of ol.commentlist based on the selection.

    Thanks for the tips BCWorkz! I’ll have a play and see what’s what.

    Did you get the code done ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sort comments by custom field (dropdown)’ is closed to new replies.