Title: Front end comment sorting
Last modified: August 21, 2016

---

# Front end comment sorting

 *  [jdpfresh](https://wordpress.org/support/users/jdpfresh/)
 * (@jdpfresh)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/front-end-comment-sorting/)
 * I’m trying to figure out a way to sort my comments. I’m using the comments rating
   plugin which adds karma to the comment.
 * I want viewers to be able to sort the comments from newest to oldest and from
   highest rated karma to lowest.
 * I’ve figured out how to sort them, but I DO NOT know how to create a link or 
   interface that gives viewers the option to select different sort methods.
 * I tried this method: [http://www.jacklmoore.com/notes/jquery-tabs/](http://www.jacklmoore.com/notes/jquery-tabs/)
   –
   It works in displaying the comments, but the comment form seems to only process
   on the default tab — this means when I click reply on a comment that is on the
   2nd tab, the comment form collapses on the first tab. Is there maybe a way to
   reload the content so it thinks its a fresh process when clicking between the
   tabs?
 * Any other suggestions? I’ve been researching for hours on end per day and this
   is stumping me 🙁
 * Thanks guys!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/front-end-comment-sorting/#post-3959432)
 * Use AJAX like techniques to re-query the comments and generate new content for
   the comments container. Place some element on your comment template that users
   can interact with, it can be text, a button, a pulldown field, an image, whatever.
   Some event like a click or change on this element will trigger a jQuery .post()
   request to WP’s AJAX handler with the post ID and orderby parameters.
 * Your PHP AJAX callback will take the POSTed data and form a new comment query
   ordered appropriately and generate content in the same manner as the comment 
   template would. The jQuery .post() callback receives this content and replaces
   the old comment content in the comments container with the new content.
 *  Thread Starter [jdpfresh](https://wordpress.org/support/users/jdpfresh/)
 * (@jdpfresh)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/front-end-comment-sorting/#post-3959433)
 * Thank you for the response, unfortunately, I do not know any jquery or ajax —
   so I am a little lost. Maybe you can link me to something more in depth? So sorry:/
 * THANKS!
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/front-end-comment-sorting/#post-3959447)
 * Well, there’s [AJAX in Plugins](http://codex.wordpress.org/AJAX_in_Plugins). 
   It leaves something to be desired, unfortunately. The Further Reading links are
   helpful though.
 * Perhaps the first step in implementing this is to alter your comment template
   to accept orderby arguments POSTed (or GET’d) by a conventional HTML form, resulting
   in simply reloading the entire page with the revised comment sort.
 * Once you get the mechanics of that working, you can focus on the AJAX portion
   to achieve the more interactive, seamless user experience you are looking for.
 * A divide and conquer approach with usable intermediate results will make learning
   new techniques more enjoyable and rewarding IMO. Good luck.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Front end comment sorting’ is closed to new replies.

## Tags

 * [ajax](https://wordpress.org/support/topic-tag/ajax/)
 * [comment](https://wordpress.org/support/topic-tag/comment/)
 * [end](https://wordpress.org/support/topic-tag/end/)
 * [front](https://wordpress.org/support/topic-tag/front/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/front-end-comment-sorting/#post-3959447)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
