The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Sort comments by custom field (dropdown) (4 posts)

  1. lokust
    Posted 3 years ago #

    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.



  2. bcworkz
    Posted 3 years ago #

    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.

  3. lokust
    Posted 3 years ago #

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

  4. arulpr
    Posted 2 years ago #

    Did you get the code done ?

Topic Closed

This topic has been closed to new replies.

About this Topic