WordPress函数文档comments_number()
显示当前文章的评论数量 描述 Displays the total number of comments, T…
显示当前文章的评论数量
描述
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.
用法
<?php comments_number( $zero, $one, $more ); ?>
参数
$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’
示例
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.
1
2
3
4
5
6
7
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
<p>
This post currently has
<?php comments_number( ‘no responses’, ‘one response’, ‘% responses’ ); ?>.
</p>
|
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.
1
2
3
4
5
6
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
<h3>
printf( _nx( ‘One Comment’, ‘%1$s Comments’, get_comments_number(), ‘comments title’, ‘textdomain’ ), number_format_i18n( get_comments_number() ) );
</h3>
|
历史
添加于 版本: 0.71
源文件
comments_number() 函数的代码位于 wp-includes/comment-template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* Display the language string for the number of comments the current post has.
*
* @since 0.71
*
* @param string $zero Optional. Text for no comments. Default false.
* @param string $one Optional. Text for one comment. Default false.
* @param string $more Optional. Text for more than one comment. Default false.
* @param string $deprecated Not used.
*/
function comments_number( $zero = false, $one = false, $more = false, $deprecated = ” ) {
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, ‘1.3’ );
}
echo get_comments_number_text( $zero, $one, $more );
}
|
相关
Comments Function(函数)s
- Function(函数): cancel_comment_reply_link()
- Function(函数): comment_author()
- Function(函数): comment_author_email()
- Function(函数): comment_author_email_link()
- Function(函数): comment_author_IP()
- Function(函数): comment_author_link()
- Function(函数): comment_author_rss()
- Function(函数): comment_author_url()
- Function(函数): comment_author_url_link()
- Function(函数): comment_class()
- Function(函数): comment_date()
- Function(函数): comment_excerpt()
- Function(函数): comment_form_title()
- Function(函数): comment_form(),
- Function(函数): comment_ID()
- Function(函数): comment_id_fields()
- Function(函数): comment_reply_link()
- Function(函数): comment_text()
- Function(函数): comment_text_rss()
- Function(函数): comment_time()
- Function(函数): comment_type()
- Function(函数): comments_link
- Function(函数): comments_number()
- Function(函数): comments_open(),
- Function(函数): comments_popup_link()
- Function(函数): comments_popup_script()
- Function(函数): comments_rss_link()
- Function(函数): get_avatar()
- Function(函数): next_comments_link()
- Function(函数): paginate_comments_links()
- Function(函数): permalink_comments_rss()
- Function(函数): previous_comments_link()
- Function(函数): wp_list_comments()
- 原文:http://codex.wordpress.org/Function_Reference/comments_number
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!