comments_per_page

最后更新于:2021-11-26 00:45:16

apply_filters( ‘comments_per_page’, int $comments_per_page, string $comment_status )

Filters the number of comments listed per page in the comments list table.

参数

$comments_per_page

(int)
The number of comments to list per page.

$comment_status

(string)
The comment status name. Default ‘All’.

源文件

文件: gc-admin/includes/class-gc-comments-list-table.php

View on Trac

/**
 * Increase comments-per-page limit when viewing spam comments.
 *
 * @see GC_Comments_List_Table::get_per_page()
 *
 * @param int    $comments_per_page The number of comments to list per page.
 * @param string $comment_status    The current comment status view. Default is 'all'.
 * @return int The filtered number of comments to list per page.
 */
function gcdocs_spam_comments_per_page( $comments_per_page, $comment_status ) {
	if ( 'spam' == $comment_status ) {
		$comments_per_page = 50;
	}
	return $comments_per_page;
}
add_filter( 'comments_per_page', 'gcdocs_spam_comments_per_page', 10, 2 );