I've created a custom theme from scratch, nothing fancy, simple theme. I'm currently using Wordpress 3.2.1. I put wp_list_comments() in the comments.php to list the comments, and it doesn't work at all! No comments displayed. Tried putting it in single.php, tried also deactivating all the plugins - still nothing. I used the default function, just wp_list_comments(); with no arguments. Could anybody suggest why it might be not working?
3 Answers
Did you try <?php comments_template(); ?>
in single.php? You seem to imply in your comment above that you were doing something like <?php include('comments.php')?>
This won't work, because the comments haven't been queried from the database--comments_template()
does that, then includes comments.php
in your theme root.
Does that help?
-
-
Thank you. Nothing like a function you have to call client side to query for data that includes your markup... ;)– benipsenNov 27, 2016 at 23:35
I had same problem. I added
<?php include('comments.php')?>
and comments started to appear.
My resolution was to load the comments and include them as the argument in the wp_list_comments() function call. In this case, it's to include Woocommerce comments and their associated formatting.
<?php
$comments = get_comments( array('post_id' => get_the_id()) );
?>
<ol class="commentlist">
<?php wp_list_comments( apply_filters( 'woocommerce_product_review_list_args', array( 'callback' => 'woocommerce_comments' ) ), $comments ); ?>
</ol>
<?php comment_form(array('title_reply'=>'Leave a Comment', 'comment_notes_before'=>'', 'comment_notes_after'=>'')); ?> <?php wp_list_comments(); ?>
And then I included that comments.php into my single.php The first part of the code (Leave a Comment form) shows, the list of existing comments does not.