comments_open
Filters whether the current post is open for comments.
Usage
add_filter( 'comments_open', 'wp_kama_comments_open_filter', 10, 2 ); /** * Function for `comments_open` filter-hook. * * @param bool $comments_open Whether the current post is open for comments. * @param int $post_id The post ID. * * @return bool */ function wp_kama_comments_open_filter( $comments_open, $post_id ){ // filter... return $comments_open; }
- $comments_open(true|false)
- Whether the current post is open for comments.
- $post_id(int)
- The post ID.
Changelog
Since 2.5.0 | Introduced. |
Where the hook is called
comments_open
wp-includes/comment-template.php 1323
return apply_filters( 'comments_open', $comments_open, $post_id );
Where the hook is used in WordPress
wp-includes/default-filters.php 307
add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 );