如何使wordpress评论与以下内容配合使用:
include(TEMPLATEPATH."/comments.php");
而不是:comments_template( \'\', true );
有什么想法吗?泰如何使wordpress评论与以下内容配合使用:
include(TEMPLATEPATH."/comments.php");
而不是:comments_template( \'\', true );
有什么想法吗?泰简短回答:你不能。
更长的答案:
您可以包括comments.php
作为另一个模板中的模板部分,通过:
get_template_part( \'comments.php\' )
。。。但这实际上不会让评论起作用,因为comments_template()
模板标记不仅仅包括comments.php
模板零件文件。为了在使用get_template_part()
而不是comments_template()
, 你需要复制all of the functions performed by comments_template()
. 如果您需要复制所有这些代码以使注释生效,那么您也可以使用函数本身。这行不通,因为我们不能包括comments.php
文件作为模板文件。我们的comments.php
文件不包含对数据库执行SQL操作和获取要显示的注释所需的代码。
因此,我们应该调用函数,而不是将该文件作为模板文件包含comments_template()
显示注释。
Wordpress使用comments_template()
函数获取文件并显示注释,如果我们不提供文件变量wordpress使用默认值comments.php
处理结果。
<?php comments_template( \'/comments2.php\' ); ?>
参考-Comments_template当前在评论部分,如果您(管理员)想要回复待定的评论,可能是警告他们或其他什么,发送回复的唯一方法是单击“批准并回复”。在批准评论之前,是否有办法向提交的电子邮件地址发送私人消息(除了手动编写电子邮件)?