I want to modify comments form for both logged in users, and for those who are not.

I modified the form for those who are not logged in by changing my comments.php but I'm not quite sure how to modify my form for logged in users. I know I have to use comments_template(), but when ever I try to use it in my page.php, I get errors like this

Notice: Undefined variable: args in {PATH}/twwr-theme/comments-template.php on line 13 

these are the contents of my comments.php, its a bit messy

if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    die ('Please do not load this page directly. Thanks!');

if ( post_password_required() ) {
    echo "This post is password protected. Enter the password to view comments.";
<h3><?php comments_number('No Comments', 'One Comment', 'Comments' );?></h3>

<div class="navigation">
    <div class="next-posts"><?php previous_comments_link() ?></div>
    <div class="prev-posts"><?php next_comments_link() ?></div>

<ul class="commentlist">
    <?php //comment layout is in functions.php ?>
    <?php wp_list_comments('callback=comment_layout'); ?>

<div class="navigation">
    <div class="next-posts"><?php previous_comments_link() ?></div>
    <div class="prev-posts"><?php next_comments_link() ?></div>
<?php if ( comments_open() ) : ?>
    <!-- If comments are open, but there are no comments. -->

 <?php else : // comments are closed ?>
    <p>Comments are closed.</p>

<?php endif; ?>
ID); ?>
  • The file is named comments.php usually. You can use another name, but that is not required. Add the code of your comment file to the question.
    – fuxia
    Commented Oct 22, 2012 at 3:35

1 Answer 1


It depends on how your theme is built & we can't be 100% sure if this is right without seeing the code but most probably comments_template is the wrong function. Take a look at the comment_form function http://codex.wordpress.org/Function_Reference/comment_form

comments_template is the function generally used to include the comments file(basically to display the contents of comments.php, though this can be changed)

Again, it's possible for the theme to use comments_template for displaying the form & if the above doesn't work for you, please post the code

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.