Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

<?php
// Is the post password protected?  Maybe you want to deal with that.
if(post_password_required())
{
    // show a message to the users about the password requirement.

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

// display the comments if they exist
if(have_comments())
{
    // 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
    wp_list_comments();

    // 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!
if(comments_open())
{
    // `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
    comment_form();
}
else
{
    // 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.

share|improve this answer
    
Thanks a lot, chrisguitarguy. I'll study your code and links, and hope this will be solved. –  Alegro Dec 3 '12 at 5:40

Your Answer

 
discard

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.