has_block


has_block ( $block_type, $post = null )

Parameters:
  • (string) $block_type 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

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

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

Related Functions

has_blocks, parse_blocks, do_blocks, render_block, has_shortcode

Top Google Results

User discussions

wpseek mobile