using comments_template() outside of single.php (2 posts)

  1. robodevil
    Posted 5 years ago #

    This is not working the way I anticipated (a common theme).

    <?php comments_template(); ?> does nothing when it is inside the loop on any page except single.php, although it works perfectly fine on single.php

    If I change this to <?php include("comments.php" ?>, the file includes. It will behave properly as far as telling me if comments are locked - and it will give me the reply form. It will also tell me how many comments are on the page using the standard comments_number() function, and comments_popup_link() works as well.

    However, $comments appears to be empty. If I echo it, I get nothing, and no comments are ever shown, even when the page itself tells me that there are comments there. Again, the same code, no exceptions, works brilliantly on single.php

    Any ideas?

  2. Michael
    Part-Time Forum Moderator
    Posted 5 years ago #

    you could try and add this before comments_template() :

    $withcomments = 1;
    comments_template(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic