WordPress模板层次13:comments.php

模板层次 虚幻 770℃ 0评论

博客文章模板中调用:评论模板comments.php

在博客文章模板single.php的下半部分,注意到有一个叫做 comments_template();的模板标签,它会调用comments.php:

				<?php endwhile; endif; ?>

				<?php comments_template(); ?>/***调用comments.php***/

	    	</div>

	    	<?php get_sidebar( 'blog' ); ?>

	    </div>

    </div>

<?php get_footer(); ?>

comments.php模板

comments.php模板包含用于创建博客文章的评论表单的所有代码。

登录状态下的评论表单就像这个样子:

comment.php wordpress xuhss.com01 - WordPress模板层次13:comments.php

如果当我退出登录时,你会看到:这和登录状态下的评论表单字段显示是不同的

comment.php wordpress xuhss.com02 - WordPress模板层次13:comments.php

具体取决于我是否登录。

总结的说,所有的评论表单的输出,都是由comments.php模板控制的。

一般来说,我们不需要自定义comments.php模板。但是,如果你想自定义它,最好的办法就是先去另一个默认的WordPress主题,找到comments.php文件,并在它的基础上进行修改,因为这会帮助你考虑到更多的情况,省下不必要的时间浪费。

转载请注明:虚坏叔叔 » WordPress模板层次13:comments.php

喜欢 (3)

您必须 登录 才能发表评论!