https://codex.wordpress.org/Function_Reference/get_comments
add 'post_id', with the value of the current post, to the parameters
https://codex.wordpress.org/Function_Reference/get_comments
add ‘post_id’, with the value of the current post, to the parameters
Michael, thanks so much for your reply. I did some digging and your solution was perfect. I actually tried it before using arguments in the array without luck by having this:
$comments = get_comments(array( 'post_id' => the_ID()));
That was interestingly injecting the post ID number to the page, so I figured it was partially working. I switched it to this and it worked like a charm:
$comments = get_comments(array( 'post_id' => get_the_ID()));
Thanks again!
(@sheva29)
10 years, 1 month ago
Hello,
There is this post about the difference between comments_template() and comment_form.
That makes sense, from a hierarchical standpoint I’m not sure though. I’m creating my own WP template but the default fields that the form return are good enough for me. So I don’t need to do any customization, I just use CSS to style the default one, suing its classes and JS to add the ones that I want to add. I tried using the following in my single.php:
This works partially, the only problem is that, it will display all my comments in every single post page. Not the comments that belong to a particular post. Can anyone provide more insights in why this is happening? I feel that I’m missing something. And also, if one could expand more on comments_template() vs comment_form() it will be highly appreciated it.
Thanks!