has_blocks

SummerySummery

Determine whether a post or content string has blocks.

Syntax

has_blocks( int|string|WP_Post|null $post = null )

DescriptionDescription

This test optimizes for performance rather than strict accuracy, detecting the pattern of a block but not validating its structure. For strict accuracy, you should use the block parser on post content.

ParametersParameters

$post

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

Default value: null

ReturnReturn

(bool) Whether the post has blocks.

SourceSource

File: wp-includes/blocks.php


			

ChangelogChangelog

Changelog
Version Description
5.0.0 Introduced.

See alsoSee also

Scroll to Top