• I found a post describing a similar problem, but couldn’t understand the response. I have a line:

    <a href='<?php comments_link(); ?>'><font color='#374a5f' size='2'>Comment</font>

    And it appears whether comments are enabled or not. I’m sure there’s an if statement I can put it into, but I’ve scoured template tags and can’t find the property of the post that says whether or not comments are enabled – only the one that says whether or not it’s got any yet. I tried $comments, but that stopped the link appearing on any posts, even if they had comments enabled.

    Any help greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try this:

    <?php if ('open' == $post->comment_status) : ?>
    <a href='<?php comments_link(); ?>'><font color='#374a5f' size='2'>Comment</font>
    <?php endif; ?>

    Thread Starter pentadact

    (@pentadact)

    Brilliant! Just what I was looking for. Thanks Kafka.

    It took me a while to figure out which file to edit on my wordpress blog because I use a completely different template. (Just in case others are as dim as I, the file that is to be altered is index.php in the theme folder.)

    This is what I have now (that works beautifully):

    <?php
    // disable comments link if comments are disabled
    if ('open' == $post->comment_status) : ?>
    <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
    <?php endif;
    // end of disabling comments link if comments are disabled
    ?>

    However, the coding looks decidedly unwieldy. I’m not very savvy about php. How do I achieve something the same in a cleaner way?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Comments Link Still Appears When Comments Are Disabled For The Post’ is closed to new replies.