“Leave a comment” link even when you can’t

In the loop.php template file, you will find this line:

<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>

If you don’t want “leave a comment” to display if comments are closed, you can wrap the call to comments_popup_link() in a if ( comments_open() ) conditional, like such:

<span class="comments-link"><?php if ( comments_open() ) comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>

Note: you may also want to check the other loop-foobar.php template files.

Leave a Comment