1

How can I make the wordpress comments work with:

include(TEMPLATEPATH."/comments.php");

instead of:

comments_template( '', true );

Ay ideas? Ty

  • 2
    why do you want to do that? answer is probably you can't do it anyway; comments_template() is actually checking and preparing a lot of needed stuff before calling the comments.php file. – Michael Aug 4 '12 at 13:28
4

Short answer: you can't.

Longer answer:

You can include comments.php as a template-part file inside another template, via:

get_template_part( 'comments.php' )

...but that won't actually make comments work, because the comments_template() template tag does far more than merely include the comments.php template-part file. In order to make comments actually work when using get_template_part() as opposed to comments_template(), you'd need to duplicate all of the functions performed by comments_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.

| improve this answer | |
0

That wont work because we cannot include the comments.php file as a template file. Our comments.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 default comments.php to process the result.

Note -

If you're curious about how to load a different comment template then here's the code

<?php comments_template( '/comments2.php' ); ?> 

Reference - Comments_template

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.