Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

have_comments() returns false [with comments_template()]

Tags:

wordpress

My wordpress installation is behaving very strangely. First the recent posts stopped working, now this...

I'm working on my custom wordpress theme and I got stuck on the comments. Actually, I just copied the code for the comments template and the 3 functions from this tutorial.

I found a solution that says I should call the template with comments_template() instead of the general include method and that is how I do it. It still doesn't show a single comment, even though get_comments_number() returns 2 and I see the comments in the dashboard.

Any ideas ?

like image 621
Mariano Grandioso Avatar asked Jun 30 '26 01:06

Mariano Grandioso


1 Answers

I did suck with this also 5 mins ago.

Yes, you should call this comments_template() function.

Call it like this:

comments_template( '', true);

and then make a comments.php in your theme directory, and do the

 if (have_comments()) {
    ...
}

cycle.

It should work.

like image 147
vaso123 Avatar answered Jul 01 '26 19:07

vaso123



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!