Pedro Rodrigues

home github

Hiding comments_template() call

While working on my template that comments_template() was being called for all pages and posts even if the comments were disabled.

Here’s the solution I used: This is the original piece of code on the template:

<!--?php comments_template(); // Get wp-comments.php template ?-->

This will show the comments template even if you have disabled comments for a certain post/page, to fix this all you need is to confirm weather comments are active or not for this post/page:

<!--?php if (comments_open()) { comments_template(); // Get wp-comments.php template } ?-->

Read or