get_comment_pages_count()获取评论分页总数

目录

描述

Calculate the total number of comment pages.

This function lets you calculate how many pages of comments there will be for a post, given the number of comments to show per page, and whether the comments should be threaded or not.

get_comment_pages_count() 描述

用法

<?php get_comment_pages_count$comments$per_page$threaded); ?>

get_comment_pages_count() 用法

参数

$comment

(array) (可选) array of comment objects. If empty, $wp_query->comments will be used.

默认值: null

$per_page

(integer) (可选) comments per page.

默认值: null

$threaded

(boolean) (可选) control over flat or threaded comments.

默认值: null

get_comment_pages_count() 参数

返回值

(float

Number of comment pages.

get_comment_pages_count() 返回值

示例

This function can be used within the loop like this:

This will use the defaults for the number of comments per page and threading. You can use custom values like this:

When inside the loop, you can just pass null as the value for the $comment parameter, as shown above. You can also use the function outside the loop, but you need to pass in the array of comments. For example, you may perform a custom comment query using WP_Comment_Query:

get_comment_pages_count() 示例

注意

  • Typically you cannot use this function before the The Loop has started.

get_comment_pages_count() 注意

历史

添加于 版本: 2.7.0

get_comment_pages_count() 历史

源文件

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

get_comment_pages_count() 源文件