Action hook 'wp_update_comment_count'

in WP Core File wp-includes/comment.php at line 2827

View Source

wp_update_comment_count

Action Hook
Description
Fires immediately after a post's comment count is updated in the database.

Hook Information

File Location wp-includes/comment.php View on GitHub
Hook Type Action
Line Number 2827

Hook Parameters

Type Name Description
int $post_id Post ID.
int $new The new comment count.
int $old The old comment count.

Usage Examples

Basic Usage
<?php
// Hook into wp_update_comment_count
add_action('wp_update_comment_count', 'my_custom_function', 10, 3);

function my_custom_function($post_id, $new, $old) {
    // Your custom code here
}

Source Code Context

wp-includes/comment.php:2827 - How this hook is used in WordPress core
<?php
2822  	 *
2823  	 * @param int $post_id Post ID.
2824  	 * @param int $new     The new comment count.
2825  	 * @param int $old     The old comment count.
2826  	 */
2827  	do_action( 'wp_update_comment_count', $post_id, $new, $old );
2828  
2829  	/** This action is documented in wp-includes/post.php */
2830  	do_action( "edit_post_{$post->post_type}", $post_id, $post );
2831  
2832  	/** This action is documented in wp-includes/post.php */

PHP Documentation

<?php
/**
	 * Fires immediately after a post's comment count is updated in the database.
	 *
	 * @since 2.3.0
	 *
	 * @param int $post_id Post ID.
	 * @param int $new     The new comment count.
	 * @param int $old     The old comment count.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 3
  • File: wp-includes/comment.php
Related Hooks

Related hooks will be displayed here in future updates.