wp_update_comment_count_now [ WordPress Function ]
wp_update_comment_count_now ( $post_id )
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: wp_update_comment_count, wp_update_term_count_now, wp_defer_comment_counting, wp_update_comment, wp_update_term_count
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ý
- #13091 (edit_post action on wp_update_comment_count_now ...
wp_update_comment_count_now() is called whenever a comment status is transitioned (or a comment is deleted). However, if the comment transition is not ...
core.trac.wordpress.org - wp_update_comment_count_now | A HitchHackers guide through ...
Feb 12, 2011 ... Source code. function wp_update_comment_count_now($post_id) { global $ wpdb; $post_id = (int) $post_id; if ( !$post_id ) return false; if ( !
hitchhackerguide.com - wp_update_comment_count_now() WordPress function reference ...
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 ...
queryposts.com - Wordpress: wp_insert_post fails to add comment_count - Stack ...
wp_insert_post() does not update the comment count, you have to call wp_update_comment_count_now() to update accomplish that.
stackoverflow.com