trash_post_comments
Action HookDescription
Fires before comments are sent to the Trash.Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Action |
Line Number | 4136 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$post_id
|
Post ID. |
Usage Examples
Basic Usage
<?php
// Hook into trash_post_comments
add_action('trash_post_comments', 'my_custom_function', 10, 1);
function my_custom_function($post_id) {
// Your custom code here
}
Source Code Context
wp-includes/post.php:4136
- How this hook is used in WordPress core
<?php
4131 *
4132 * @since 2.9.0
4133 *
4134 * @param int $post_id Post ID.
4135 */
4136 do_action( 'trash_post_comments', $post_id );
4137
4138 $comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );
4139
4140 if ( ! $comments ) {
4141 return;
PHP Documentation
<?php
/**
* Fires before comments are sent to the Trash.
*
* @since 2.9.0
*
* @param int $post_id Post ID.
*/
Quick Info
- Hook Type: Action
- Parameters: 1
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.