WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. lokust
    Member
    Posted 1 year 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.

    Thanks,

    Al

  2. bcworkz
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

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

  4. arulpr
    Member
    Posted 5 months ago #

    Did you get the code done ?

Topic Closed

This topic has been closed to new replies.

About this Topic