Because comments are so important on a blog, it stands to reason that the best place to start is with how to display an appropriate comment form on each post. The comment form allows the appropriate visitors to leave comments with their name, e-mail address, and URL. The form presented in this recipe is the standard comment form that the default WordPress theme uses.
The first thing you need to do here is to open your single content template, either single.php
or page.php
, and insert the appropriate template tag. Scroll to the end of your post display code, and insert the following function call:
<?php comments_template(); ?>
Open up your site and browse to a single post. Upon arriving there, you should see one of two things. If you are logged in, you'll see a notice indicating your username and a Log out link, as well as the comment input box. This is shown as follows:
If you are not logged in, you'll see a Name, Mail, and Website...