Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_comments_number [ WordPress Function ]

get_comments_number ( $post_id = 0 )
Parameters:
  • (int) $post_id The Post ID
Uses:
Returns:
  • (int) The number of comments a post has
Defined at:



Retrieve the amount of comments a post has.

Source


<?php
function get_comments_number$post_id ) {
    
$post_id absint$post_id );

    if ( !
$post_id )
        
$post_id get_the_ID();

    
$post get_post($post_id);
    if ( ! isset(
$post->comment_count) )
        
$count 0;
    else
        
$count $post->comment_count;

    return 
apply_filters('get_comments_number'$count$post_id);
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics