5

I am working on a client site which is a very stripped down theme. It has no standard html markups as a result of which the reply box doesn't move upto the place of being just below the comment to which you hit the reply button. Can anyone point me to the minimum markup required? I am trying to add classes one by one.

Trying to explain it better: I click on the reply button, the page reloads and the comment form stays below all the comments list. I want it to make it work like when we click on reply button, then without any page reload, it jumps up there and can be cancelled back to the place. The default what we have in Twentyten

Update: I managed to fix up the markup and now I am using comment_form() but cancel reply button doesn't appear and I am not filtering that out. Any ideas?

Done So sorry to trouble everyone here. The last issue was fixed by removing the CSS display:none; ( Lesson - DIY Themes sucks unless its what you do! ;) )

2
  • are you using jQuery? You can easily reproduce what comment-reply.js does with jQuery... Commented Feb 3, 2011 at 9:49
  • No I am using the WordPress comment reply script
    – Ashfame
    Commented Feb 3, 2011 at 15:22

4 Answers 4

5

You should really use comment_form() instead of rolling your own.

Still, if you must, make sure that:

  1. The textarea has id="comment".
  2. The wrapping container around the entire comment form (probably a DIV) has id="respond".
4
  • Yes Otto I totally understand the benefits of using comment_form() but in this case I must fix this up as it is as its someone else mess and I am not up for a cleanup. I checked the textarea does have id="comment" & the comment form is wrapped up in DIV id="respond" but it still doesn't move up on clicking the reply button & the page reloads
    – Ashfame
    Commented Feb 3, 2011 at 14:52
  • Small issue remains that 'Cancel reply' link doesn't appear when I am using comment_form() and I am not filtering it out.
    – Ashfame
    Commented Feb 3, 2011 at 20:45
  • This seems to be the most logical answer if someone come searching for the same problem, so I am marking this as the answer.
    – Ashfame
    Commented Feb 3, 2011 at 20:57
  • Are you enqueueing the comment-reply javascript as well? As for the cancel, you'll need to add the cancel_comment_reply_link() function in there as well. Try going through this post I wrote a couple years ago for all these details: ottopress.com/2008/wordpress-2-7-comments-enhancements
    – Otto
    Commented Feb 5, 2011 at 9:15
4

It is good practice to use comment_form() (customized via hooks, if needed) over manually putting form together.

For internals of comment reply script and stuff it targets see wp-includes/js/comment-reply.dev.js.

2
  • Yes I agree but I am just fixing this up for a client so can't clean up the mess.
    – Ashfame
    Commented Feb 3, 2011 at 14:17
  • Small issue remains that 'Cancel reply' link doesn't appear when I am using comment_form() and I am not filtering it out.
    – Ashfame
    Commented Feb 3, 2011 at 20:48
3

take a look at comment_form();

and probably add wp_enqueue_script( 'comment-reply' ); in your theme's header.php

6
  • I have the script loaded. I need to find out what class it targets in the html
    – Ashfame
    Commented Feb 2, 2011 at 22:32
  • What do you mean by "what class it targets"?
    – Bainternet
    Commented Feb 2, 2011 at 23:03
  • Like $("#main") targets main ID
    – Ashfame
    Commented Feb 3, 2011 at 14:12
  • so you want to ajax submit your comments?
    – Bainternet
    Commented Feb 3, 2011 at 15:34
  • No I want the default Twentyten functionality. Comment form jumps up to the comment we are replying. Right now this doesn't happen & page reloads
    – Ashfame
    Commented Feb 3, 2011 at 16:06
0
  1. You will have to enqueue 'comment-reply' script.
  2. Make sure your comment list (single comment markup li tag) has id="comment-12". Replace 12 with the correct comment id. This li tag should also display the necessary comment classes.
  3. The li tag should have a children like <article id="div-comment-<?php echo esc_attr( comment_ID( ) ); ?>" class="comment-body">{{all of the comment elements go here}}</article>.
  4. The rest of the comment elements(author name, date, reply link etc) everything should be inside that article tag.

Not the answer you're looking for? Browse other questions tagged or ask your own question.