开发者

wp_list_comments() not working

I've created a custom theme from scratch, nothing fancy, simple theme. I'm currently using Wordp开发者_JAVA技巧ress 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?


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?


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜