1. 首页
  2. WordPress 函数手册

has_block()

has_block( string $block_name, int|string|WP_Post|null $post = null )

确定$post或字符串是否包含特定的块类型。
Determine whether a $post or a string contains a specific block type.

目录锚点:#说明#参数#返回#源码


说明(Description)

另见函数 parse_blocks()


参数(Parameters)

参数 类型 必填 说明
$block_name (string) 必需 要查找的完整块类型。
$post (int | string | WP_Post | null) 可选 Post内容、Post ID或Post对象。默认为全局$post。

返回(Return)

(bool)post内容是否包含指定的块。


源码(Source)


更新版本 源码位置 使用 被使用
5.0.0 wp-includes/blocks.php:81 1 function 3

has_block() 为WP2原创文章,链接:https://www.wp2.cn/functions/has_block/