wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



get_comments_number › WordPress Function

Depuis1.5.0
Dépréciéen/a
get_comments_number ( $post = 0 )
Paramètres:
  • (int|WP_Post) $post Optional. Post ID or WP_Post object. Default is the global `$post`.
    Requis: Non
    Défaut:
Retourne:
  • (string|int) If the post exists, a numeric string representing the number of comments the post has, otherwise 0.
Défini(e) dans:
Codex:

Retrieves the amount of comments a post has.



Source

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 );
}