comments_open()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
comments_open( int|WP_Post $post = null ): bool
Описание
Дополнительные сведения об этой и похожих функциях темы см. в статье о Conditional Tags в Theme Developer Handbook.
Оригинал (английский)
For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.
Параметры
$post
int|WP_Post
необязательный
= null
Возвращаемое значение
bool
Исходный код
wp-includes/comment-template.php:1311
function comments_open( $post = null ) {
$_post = get_post( $post );
$post_id = $_post ? $_post->ID : 0;
$comments_open = ( $_post && ( 'open' === $_post->comment_status ) );
/**
* 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.
*/
return apply_filters( 'comments_open', $comments_open, $post_id );
}
История изменений
| Версия | Описание |
|---|---|
| 1.5.0 | Introduced. |

