钩子文档

get_default_comment_status

💡 云策文档标注

概述

get_default_comment_status 是一个 WordPress 过滤器,用于修改指定文章类型的默认评论状态。它允许开发者自定义评论的初始开启或关闭状态。

关键要点

  • 这是一个过滤器 Hook,用于过滤默认评论状态。
  • 接受三个参数:$status(默认状态,'open' 或 'closed')、$post_type(文章类型,默认为 'post')、$comment_type(评论类型,默认为 'comment')。
  • 返回应用过滤器后的状态值。

代码示例

apply_filters( 'get_default_comment_status', $status, $post_type, $comment_type );

注意事项

  • 该过滤器在 WordPress 4.3.0 版本中引入。
  • 相关函数 get_default_comment_status() 用于获取文章类型的默认评论状态。

📄 原文内容

Filters the default comment status for the given post type.

Parameters

$statusstring
Default status for the given post type, either 'open' or 'closed'.
$post_typestring
Post type. Default is post.
$comment_typestring
Type of comment. Default is comment.

Source

return apply_filters( 'get_default_comment_status', $status, $post_type, $comment_type );

Changelog

Version Description
4.3.0 Introduced.