comments_number()显示当前文章的评论数量

目录

描述

Displays the total number of comments, Trackbacks, and Pingbacks for the current post. This tag must be within The Loop.

Use get_comments_number() to retrieve the value.

comments_number() 描述

用法

 <?php comments_number$zero$one$more ); ?> 

comments_number() 用法

参数

$zero

(string) (可选) Text to display when there are no comments.

默认值: 'No Comments'

$one

(string) (可选) Text to display when there is one comment.

默认值: '1 Comment'

$more

(string) (可选) Text to display when there is more than one comment. % is replaced by the number of comments, so '% so far' is displayed as "5 so far" when there are five comments.

默认值: '% Comments'

comments_number() 参数

示例

Text Response to Number of Comments

Displays text based upon number of comments: Comment count zero - no responses; comment count one - one response; more than one comment (total 42) displays 42 responses.

Title For Comments Section

You might want to have a title above your comments section that includes the number of comments. This example shows how to do that and have all the strings also be translatable.

comments_number() 示例

历史

添加于 版本: 0.71

comments_number() 历史

源文件

comments_number() 函数的代码位于 wp-includes/comment-template.php

comments_number() 源文件

相关