首页 WordPress函数大全 has_block()

has_block()

2020-05-02 / 3635阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

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

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 id="see-also" tabindex="-1">See also See also

  • parse_blocks()

Top ↑

参数

$block_name

(string)
(Required)
Full Block type to look for.

$post

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

Default value: null

返回

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

大家谈论
    我的见解