has_block


has_block ( $block_name, $post = null )

Parameters:
  • (string) block_name Full block type to look for.
  • (int|string|WP_Post|null) post Optional. Post content, post ID, or post object. Defaults to global $post.
See:
Returns:
  • (bool) Whether the post content contains the specified block.
Defined at:

Description

Determines whether a $post or a string contains a specific block type.This test optimizes for performance rather than strict accuracy, detecting whether the block type exists but not validating its structure and not checking synced patterns (formerly called reusable blocks). For strict accuracy, you should use the block parser on post content.

Related Functions

has_blocks, parse_blocks, do_blocks, _flatten_blocks, serialize_block

Top Google Results

User discussions

wpseek mobile