WordPress.org

Support

Support » How-To and Troubleshooting » using comments_template() outside of single.php

using comments_template() outside of single.php

  • 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?

Viewing 1 replies (of 1 total)
  • Moderator Michael

    @alchymyth

    Forum Moderator

    you could try and add this before comments_template() :

    <?php
    $withcomments = 1;
    comments_template(); ?>
Viewing 1 replies (of 1 total)
  • The topic ‘using comments_template() outside of single.php’ is closed to new replies.