WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

While creating a new theme, we'll have to customize the comment flow. For doing so there are two functions: wp_list_comments() and get_comments(). I am not very sure how to style the inner elements that appear from it such as Gravatar, comment description, comment author, etc. In order to do some styling for them, I first of all need to know the DOM elements assigned to them. Where can I go to find about them?

I've tried in almost all the sources, I am unable to understand properly.

share|improve this question
Try using the Firebug add-on in Firefox, or the Developers Tools (F12) in Google Chrome – shea Dec 25 '12 at 8:11

You should use wp_list_comments(), because this will call a Walker class that can handle comment threads:

// from wp_list_comments()
if ( empty($walker) )
    $walker = new Walker_Comment;

$walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);

Walker_Comment handles the markup for the comments. You can pass a custom walker to change it.


class Simple_Comment_Walker extends Walker_Comment
    function start_el( &$output, $comment, $depth, $args, $id = 0 ) {
        $GLOBALS['comment_depth'] = $depth;
        $GLOBALS['comment'] = $comment;

        print '<li>' . get_comment_author_link() . '<br>';

wp_list_comments( array ( 'walker' => new Simple_Comment_Walker ) );

But this is not needed if you want to change the single comment markup only. You can pass a callback parameter to wp_list_comments() to do the same:

function simple_callback() 
    print '<li>' . get_comment_author_link() . '<br>';
wp_list_comments( array ( 'callback' => 'simple_callback' ) );
  • Use a custom walker if you want to change the container elements for the comment list too, use a callback if you want to change single comments only.

  • You can overwrite everything in Walker_Comment, see wp-includes/comment-template.php for details.

  • Keep in mind you should not close the first comment container (in my examples the <li>), the Walker does this when the whole thread has been printed.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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