wp_update_comment_count_now example


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

    if ( empty( $post_id ) && ! $do_deferred ) {
        return false;
    }

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

}
Home | Imprint | This part of the site doesn't use cookies.