Switch language

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




wp_update_comment_count_now [ WordPress Function ]

wp_update_comment_count_now ( $post_id )
Parameters:
  • (int) $post_id Post ID
Uses:
Returns:
  • (bool) False on '0' $post_id or if post with ID does not exist. True on success.
Defined at:



Updates the comment count for the post.

Source


<?php
function wp_update_comment_count_now($post_id) {
    global 
$wpdb;
    
$post_id = (int) $post_id;
    if ( !
$post_id )
        return 
false;
    if ( !
$post get_post($post_id) )
        return 
false;

    
$old = (int) $post->comment_count;
    
$new = (int) $wpdb->get_var$wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'"$post_id) );
    
$wpdb->update$wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) );

    
clean_post_cache$post );

    
do_action('wp_update_comment_count'$post_id$new$old);
    
do_action('edit_post'$post_id$post);

    return 
true;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



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