最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Comment Reply javascript

programmeradmin3浏览0评论

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! ;) )

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! ;) )

Share Improve this question edited Feb 3, 2011 at 20:56 Ashfame asked Feb 2, 2011 at 21:11 AshfameAshfame 3,7153 gold badges32 silver badges47 bronze badges 2
  • are you using jQuery? You can easily reproduce what comment-reply.js does with jQuery... – onetrickpony Commented Feb 3, 2011 at 9:49
  • No I am using the WordPress comment reply script – Ashfame Commented Feb 3, 2011 at 15:22
Add a comment  | 

4 Answers 4

Reset to default 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".

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.

take a look at comment_form();

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

  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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论