close_comments_for_post_types
Filter HookDescription
Closes comments on an old post. Hooked to comments_open and pings_open.Hook Information
| File Location |
wp-includes/comment.php
View on GitHub
|
| Hook Type | Filter |
| Line Number | 3494 |
Hook Parameters
| Type | Name | Description |
|---|---|---|
bool
|
$open
|
Comments open or closed. |
int
|
$post_id
|
Post ID. |
Usage Examples
Basic Usage
<?php
// Hook into close_comments_for_post_types
add_filter('close_comments_for_post_types', 'my_custom_filter', 10, 2);
function my_custom_filter($open, $post_id) {
// Your custom filtering logic here
return $open;
}
Source Code Context
wp-includes/comment.php:3494
- How this hook is used in WordPress core
<?php
3489 }
3490
3491 $post = get_post( $post_id );
3492
3493 /** This filter is documented in wp-includes/comment.php */
3494 $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
3495 if ( ! in_array( $post->post_type, $post_types, true ) ) {
3496 return $open;
3497 }
3498
3499 // Undated drafts should not show up as comments closed.
PHP Documentation
<?php
/**
* Closes comments on an old post. Hooked to comments_open and pings_open.
*
* @since 2.7.0
* @access private
*
* @param bool $open Comments open or closed.
* @param int $post_id Post ID.
* @return bool $open
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/comment.php
Related Hooks
Related hooks will be displayed here in future updates.