Comment entry screen shows even though “Allow Comments” is unchecked

On my single.php and index.php I’m including the comment entry routine with this code…

<?php if(get_option('allow_comments_posts')){comments_template();} ?>

However, when the specific post being viewed in single.php has “Allow Comments” unchecked, I don’t want the comment template to appear.

Read More

I was under the impression that the comments_template() routine automatically managed this, but apparently I need to wrap it or pass a paramater?

Related posts

Leave a Reply

1 comment

  1. As far as I remember main purpose of comments_template() is to load template and specific logic should be handled inside that template.

    Snippet from Twenty Ten comments.php:

    if ( ! comments_open() ) :
    ?>
        <p class="nocomments"><?php _e( 'Comments are closed.', 'twentyten' ); ?></p>
    <?php endif; // end ! comments_open() ?>