функция
since 1.5.0
get_comments_number()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_comments_number( int|WP_Post $post ): string|int
Описание
Получает количество комментариев к записи.
Параметры
$post
int|WP_Post
необязательный
ID записи или объект WP_Post. По умолчанию — глобальная переменная $post.
Возвращаемое значение
string|int
Исходный код
wp-includes/comment-template.php:915
function get_comments_number( $post = 0 ) {
$post = get_post( $post );
$comments_number = $post ? $post->comment_count : 0;
$post_id = $post ? $post->ID : 0;
/**
* Filters the returned comment count for a post.
*
* @since 1.5.0
*
* @param string|int $comments_number A string representing the number of comments a post has, otherwise 0.
* @param int $post_id Post ID.
*/
return apply_filters( 'get_comments_number', $comments_number, $post_id );
}
История изменений
| Версия | Описание |
|---|---|
| 1.5.0 | Introduced. |

