Filter hook 'comments_open'

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

View Source

comments_open

Filter Hook
Description
Filters whether the current post is open for comments.

Hook Information

File Location wp-includes/comment-template.php View on GitHub
Hook Type Filter
Line Number 1329

Hook Parameters

Type Name Description
bool $comments_open Whether the current post is open for comments.
int $post_id The post ID.

Usage Examples

Basic Usage
<?php
// Hook into comments_open
add_filter('comments_open', 'my_custom_filter', 10, 2);

function my_custom_filter($comments_open, $post_id) {
    // Your custom filtering logic here
    return $comments_open;
}

Source Code Context

wp-includes/comment-template.php:1329 - How this hook is used in WordPress core
<?php
1324  	 * @since 2.5.0
1325  	 *
1326  	 * @param bool $comments_open Whether the current post is open for comments.
1327  	 * @param int  $post_id       The post ID.
1328  	 */
1329  	return apply_filters( 'comments_open', $comments_open, $post_id );
1330  }
1331  
1332  /**
1333   * Determines whether the current post is open for pings.
1334   *

PHP Documentation

<?php
/**
	 * Filters whether the current post is open for comments.
	 *
	 * @since 2.5.0
	 *
	 * @param bool $comments_open Whether the current post is open for comments.
	 * @param int  $post_id       The post ID.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/comment-template.php
Related Hooks

Related hooks will be displayed here in future updates.