wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi
get_comment_count › WordPress Function
Da2.0.0
Deprecaton/a
› get_comment_count ( $post_id = 0 )
Parametri: |
|
Ritorna: |
|
Definito a: |
|
Codex: |
Retrieves the total comment counts for the whole site or a single post.
Funzioni correlate: get_comment_pages_count, get_comment_author, get_comment_type, get_comment, get_comment_date
Sorgenti
function get_comment_count( $post_id = 0 ) { $post_id = (int) $post_id; $comment_count = array( 'approved' => 0, 'awaiting_moderation' => 0, 'spam' => 0, 'trash' => 0, 'post-trashed' => 0, 'total_comments' => 0, 'all' => 0, ); $args = array( 'count' => true, 'update_comment_meta_cache' => false, 'orderby' => 'none', ); if ( $post_id > 0 ) { $args['post_id'] = $post_id; } $mapping = array( 'approved' => 'approve', 'awaiting_moderation' => 'hold', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed', ); $comment_count = array(); foreach ( $mapping as $key => $value ) { $comment_count[ $key ] = get_comments( array_merge( $args, array( 'status' => $value ) ) ); } $comment_count['all'] = $comment_count['approved'] + $comment_count['awaiting_moderation']; $comment_count['total_comments'] = $comment_count['all'] + $comment_count['spam']; return array_map( 'intval', $comment_count ); }