How can I make the wordpress comments work with:
include(TEMPLATEPATH."/comments.php");
instead of:
comments_template( '', true );
Ay ideas? Ty
How can I make the wordpress comments work with:
include(TEMPLATEPATH."/comments.php");
instead of:
comments_template( '', true );
Ay ideas? Ty
You must be logged in to post a comment.
Short answer: you can’t.
Longer answer:
You can include
comments.php
as a template-part file inside another template, via:…but that won’t actually make comments work, because the
comments_template()
template tag does far more than merely include thecomments.php
template-part file. In order to make comments actually work when usingget_template_part()
as opposed tocomments_template()
, you’d need to duplicate all of the functions performed bycomments_template()
. And if you need to duplicate all of that code in order to make comments work, you might as well just use the function itself.That wont work because we cannot include the
comments.php
file as a template file. Ourcomments.php
file doesn’t contain the necessary codes to do SQL operations on database and fetch the comments to display.So instead including that file as a template file we should call the function
comments_template()
to show the comments.WordPress uses
comments_template()
function to get the file and display the comments, if we don’t provide file variable wordpress uses defaultcomments.php
to process the result.Reference – Comments_template