Hi everyone. I'm sorry that this might be annoying, as I am posting a lot of code. Basically when comments are closed the comment form is still appearing. I want to change it so a message is displayed, something like "Comments are now closed for this entry"
I see that other people have asked this question before but I cannot seem to get it working, I don't understand where to put the code within comments.php.
If someone could please tell me the code and where to place it in comments.php I would be very grateful. I thought the best way was just to ask here and provide the code, as someone with knowledge could answer very easily!
Comments.php:
<?php
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.';
return;
}
?>
<div class="comments" id="commentsdiv">
<div id="commentsholder">
<?php if (have_comments()) : ?>
<div class="list" id="comments">
<h3 id="commentCount"><?php comments_number(__('No comments So Far'), __('1 comment so far'), __('% comments so far')); ?></h3>
<ol class="commentlist" id="commentlist">
<?php wp_list_comments('avatar_size=32'); ?>
</ol>
<span class="left"><?php previous_comments_link( '« Older Comments' ); ?></span>
<span class="right"><?php next_comments_link( 'Newer Comments »' ); ?></span>
<div class="clear"></div>
</div>
<?php endif ?>
</div>
<?php if (!isset($_GET['ajax'])) { ?>
<div class="form" id="respond">
<h3 class="respond"><?php comment_form_title('Leave a Reply', 'Leave a Reply to %s'); ?></h3>
<div id="cancel-comment-reply"><?php cancel_comment_reply_link() ?></div>
<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">logged in</a> to post a comment.</p>
<?php else : ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( $user_ID ) : ?>
<p id="login"><?php printf(__('<span class="loggedin">Logged in as <a href="%1$s" title="Logged in as %2$s">%2$s</a>.</span> <span class="logout"><a href="%3$s" title="Log out of this account">Log out?</a></span>', 'thematic'),
get_option('siteurl') . '/wp-admin/profile.php',
wp_specialchars($user_identity, true),
wp_logout_url(get_permalink()) ) ?></p>
<div>
<label for="comment">Your Comment</label>
<textarea id="comment" name="comment" tabindex="4" rows="6" cols="50"></textarea>
</div>
<?php else : ?>
<div>
<label for="author">Name: <span class="required">*</span></label>
<input type="text" name="author" id="author" tabindex="1" value="<?php echo $comment_author; ?>" />
<label for="email">Email: <span class="required">*</span></label>
<input type="text" name="email" id="email" tabindex="2" value="<?php echo $comment_email; ?>" />
<label for="url">Website URI:</label>
<input type="text" name="url" id="url" tabindex="3" value="<?php echo $comment_url; ?>" />
<label for="comment">Your Comment:</label>
<textarea id="comment" name="comment" tabindex="4" rows="8" cols="50"></textarea>
</div>
<div id="form-allowed-tags" class="form-section">
<p><span><?php _e('You may use these HTML tags and attributes:') ?></span> <code><?php echo allowed_tags(); ?></code></p>
</div>
<p><span class="required">* Required Fields</span></p>
<?php endif; ?>
<div class="clear"></div>
<?php endif; // If registration required and not logged in ?>
<div class="submit">
<div><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" /></div>
<div><?php comment_id_fields(); ?></div>
</div>
<div class="ajax">
<div id="postStatus"></div>
<div id="commentStatus"></div>
<!--<div><input type="hidden" name="comment_post_ID" value="<?php //echo $id; ?>" /></div>-->
</div>
<div class="clear"></div>
<?php //do_action('comment_form', $post->ID); ?>
</form>
</div> <!-- end form -->
<?php global $trackbacks; ?>
<?php if ($trackbacks) : ?>
<?php $comments = $trackbacks; ?>
<div class="pings">
<h3>Pingbacks/Trackbacks</h3>
<ol id="pinglist">
<?php foreach ($comments as $comment) : ?>
<?php if (get_comment_type() == 'pingback' || get_comment_type() == 'trackback') { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; /* end for each comment */ ?>
</ol>
</div>
<?php endif; ?>
<?php } ?>
</div> <!-- end comments -->