Forums

[resolved] Comments link > only on posts not pages please (3 posts)

  1. kaine83
    Member
    Posted 2 years ago #

    I have little idea what I'm doing with php & css etc, but I've found this line of code in the index.php that adds the Comments link to each page and post.

    <div class="feedback">
    <?php if (is_single()) wp_link_pages(); ?>
    <?php comments_popup_link(__('Comments (0)'), __('Comments (1)')); ?>
    </div>

    Can anyone please tell me how to change it (add in an 'if' or something) so that it only displays on posts and not on pages? Even if I set each page as no comments allowed it still prints 'Comments Off' on the page. I want to remove this text too.

    Thanks

  2. equalmark
    Member
    Posted 2 years ago #

    Try replacing it with this:

    <?php if(is_page() ) { ?>
    <!-- do nothing -->
    <?php } else { ?>
    
    <div class="feedback">
    <?php if (is_single()) wp_link_pages(); ?>
    <?php comments_popup_link(__('Comments (0)'), __('Comments (1)')); ?>
    </div>
    
    <?php } ?>
  3. kaine83
    Member
    Posted 2 years ago #

    That did the trick.

    Thank you so much for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags