Switch language

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




wp_update_comment_count [ WordPress Function ]

wp_update_comment_count ( $post_id, $do_deferred = false )
Parameters:
  • (int) $post_id Post ID
  • (bool) $do_deferred Whether to process previously deferred post comment counts
See:
Returns:
  • (bool) True on success, false on failure
Defined at:



Updates the comment count for post(s).

When $do_deferred is false (is by default) and the comments have been set to be deferred, the post_id will be added to a queue, which will be updated at a later date and only updated once per post ID.

If the comments have not be set up to be deferred, then the post will be updated. When $do_deferred is set to true, then all previous deferred post IDs will be updated along with the current $post_id.

Source


<?php
function wp_update_comment_count($post_id$do_deferred=false) {
    static 
$_deferred = array();

    if ( 
$do_deferred ) {
        
$_deferred array_unique($_deferred);
        foreach ( 
$_deferred as $i => $_post_id ) {
            
wp_update_comment_count_now($_post_id);
            unset( 
$_deferred[$i] ); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */
        
}
    }

    if ( 
wp_defer_comment_counting() ) {
        
$_deferred[] = $post_id;
        return 
true;
    }
    elseif ( 
$post_id ) {
        return 
wp_update_comment_count_now($post_id);
    }

}
?>

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