2

I am using wp_list_comments() function to draw the comment list.But,I want change many things in the form like class,styles, reply link and etc...

so please help me, How can i customize the comment listing function

Thanks

  • Do you really mean form (used to submit new comment) or listing of existing comments? – Rarst Jun 28 '11 at 13:05
  • @Rarst:listing of existing comments ! – Gowri Jun 28 '11 at 13:07
4

The wp_list_comments() call accepts a callback argument, in which you can define the specifc comment-list markup that you want. I would suggest taking a look at how TwentyTen handles the wp_list_comments() callback.

5

You could just take a look at the Codex Page for wp_list_comments which has some example code for customising comment listings.

You will see from that page that you can add a callback function to wp_list_comments which is normally used to customise how comments are listed

  • 1
    +1 I kinda forgot that it takes callback as well. That might be easier than custom Walker. – Rarst Jun 28 '11 at 13:38
  • Twenty Ten uses a comment callback function which might be a good example to start with. – Michael Jun 28 '11 at 13:59
  • 1
    Updated answer to specifically mention the callback, which was my main reason for suggesting the Codex page. – anu Jun 28 '11 at 14:03
  • Up-voted since you edited to mention the callback explicitly (thus making my answer redundant, and yours more thorough). :) – Chip Bennett Jun 28 '11 at 14:30
3

wp_list_comments() uses Walker_Comment class (that extends generic Walker) to generate output.

If you need extensive customization you should extend Walker_Comment with your own class and pass instance of it as walker argument to the function.

  • can you give me simple example. – Gowri Jun 28 '11 at 13:30
  • @gowri unfortunately nothing about walkers is simple. You need to understand first both mechanics of Walker class in WP (see linked Codex article) and concepts of PHP object inheritance. – Rarst Jun 28 '11 at 13:36
2

Comment is Easily Customaziable. for example: code for cancel the reply link

<?php cancel_comment_reply_link(); ?>

if you want custom the Text like Reply means Replace Text...

<?php cancel_comment_reply_link(text); ?>

Text to display as a link. If empty, it will return the default: 'Click here to cancel reply.'it should be work.

  • Do you think,this can solve my whole problem. because I want change many thinks in comment listing. so any other idea – Gowri Jun 28 '11 at 13:10
  • i gave the solution to change your reply link only.not to all.if you want to customize class means you will need to do some more things.... – Ramkumar M Jun 28 '11 at 13:13
  • you may go for that link – Ramkumar M Jun 28 '11 at 13:15
  • even I am not talking about canceling the reply. I just want to replace reply by some images.Anyway thanks for the reply – Gowri Jun 28 '11 at 13:16
1

I'd look at using comment_form();. It will give you a default layout of a comment form but you can pass $args to it to modify each section.

  • I am taking about comment listing – Gowri Jun 28 '11 at 13:08
  • @gowri but your question says you want to change the form... – Brady Jun 28 '11 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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