2

On http://wordpress.barrycarter.info/index.php/page/7/ I disabled comments for "USDCAD options vs CADUSD options arbitrage?", but it still has a "Leave a Comment" link.

Clicking the link takes you to http://wordpress.barrycarter.info/index.php/2011/02/25/usdcad-options-vs-cadusd-options-arbitrage-2/#respond where it, of course, shows that you can't leave a comment.

The timeline page correctly does not show the 'comment' link: http://wordpress.barrycarter.info/index.php/2011/02/

How to fix?

  • What Theme are you using? – Chip Bennett Apr 27 '11 at 16:50
  • Ahh, I see: TwentyTen. Just a minute; fix coming up. – Chip Bennett Apr 27 '11 at 16:51
2

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.

| improve this answer | |
  • This did the trick, once I realized that line appears in loop.php 3 times! – user4849 Apr 27 '11 at 17:09
  • 1
    Might be a good idea to use a child theme to avoid losing changes in future versions. – John P Bloch Apr 27 '11 at 18:41
  • Always a good reminder, John. I generally assume that a Child Theme will be the method of implementation, but that might not always be a valid assumption. :) – Chip Bennett Apr 27 '11 at 20:01