Support » Plugins » Hacks » Comment form – choosing a post to comment from a list

  • abrucius



    If you comment on a post, by default your comment is hooked to that post. Would it be possible to add a dropdown list of all posts to the comment form and than pick a post to hook the comment to?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    It’s possible. There’s probably a number of approaches. They all would involve doing a query to build the dropdown and add it to the comment form. The list can get very long, so you might limit it to the x latest posts. When building the list, don’t forget to filter for only posts for which comments are open.

    The approach I would try first is to use javascript to alter the hidden comment form field which contains the post ID on the dropdown change event. Not sure how the redirect to show the new comment would work, but it’s something to try.

    Another approach would be to find an appropriate hook in WP where you can swap in the altered post ID. You’d have to find where the $_POST[‘comment_post_ID’] gets assigned to the data which is then inserted into the DB. Hopefully there’s a hook after this and before the comment is actually inserted. Even if the comment is inserted, you could always change the data in the DB after the fact.

Viewing 1 replies (of 1 total)
  • The topic ‘Comment form – choosing a post to comment from a list’ is closed to new replies.