WPDev.one

has_block()

has_block( mixed $block_name, mixed $post = null )

Determines whether a $post or a string contains a specific block type.

Parameters 2 required

Name / Type Description
$block_name
string

Full block type to look for.

Required
mixed

(int | string | WP_Post | null) $post Optional. Post content, post ID, or post object. Defaults to global $post.

Required

Return Value

(bool)
Whether the post content contains the specified block.

Function Information

Since Version
5.0.0
Source File
wp-includes/blocks.php
Advertisement