I'm searching for some site where I can find line by line explanation of an wp theme's code.
Because, I want to implement on my site just commenting area.
I don't need sidebar, gadgets, searching, archives... all the toys.
My page has everything I need, except commenting area, but I can't find which code lines stands after pressing "submit" button.
I tried to find such a simple template - without success.

1 Answer 1


The Twenty Eleven Theme has some decent code comments that explain what's happening.

Quick and dirty overview:

All comment functionality goes in comments.php. You include it into your template with the aptly named comments_template which does a lot of stuff (sets up the current commentor, ect) other than just including `comments.php

Your comments.php template might look something like this.

// Is the post password protected?  Maybe you want to deal with that.
    // show a message to the users about the password requirement.

    // `return` out of the file, don't show anything else

// display the comments if they exist
    // maybe a header or something here

    // wp_list_comments (http://codex.wordpress.org/Function_Reference/wp_list_comments) 
    // actually displays the comments -- it will just work if
    // you use it without any arguments

    // You can also specify a custom callback to display things:
    // wp_list_comments(array('callback' => 'your_comment_callback'));

// are comments open? display the comment form!
    // `comment_form` does all the work. You can customize it
    // with arguments and filters. Like wp_list_comments this
    // will just work.
    // http://codex.wordpress.org/Function_Reference/comment_form
    // display a message about comments being close for visitors
    // this optional -- personally, I prefer to show no message.

Take a look at the Twenty Eleven's comment callback for some real insight in ways that you can display comments themselves.

  • Thanks a lot, chrisguitarguy. I'll study your code and links, and hope this will be solved.
    – Alegro
    Dec 3, 2012 at 5:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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