block_core_post_template_uses_featured_image

函数
block_core_post_template_uses_featured_image ( $inner_blocks )
参数
  • (WP_Block_List) $inner_blocks Inner block instance.
    Required:
返回值
  • (bool) Whether the block list contains a block that uses the featured image.
定义位置
相关方法
render_block_core_post_featured_imageregister_block_core_post_featured_imagerender_block_core_post_templateget_block_core_post_featured_image_border_attributesblock_core_comment_template_render_comments
引入
-
弃用
-

block_core_post_template_uses_featured_image: 该函数用于检查文章模板是否使用了特色图片。如果文章模板使用了特色图片,则返回true,否则返回false。

决定一个区块列表是否包含使用特色图片的区块。

function block_core_post_template_uses_featured_image( $inner_blocks ) {
	foreach ( $inner_blocks as $block ) {
		if ( 'core/post-featured-image' === $block->name ) {
			return true;
		}
		if (
			'core/cover' === $block->name &&
			! empty( $block->attributes['useFeaturedImage'] )
		) {
			return true;
		}
		if ( $block->inner_blocks && block_core_post_template_uses_featured_image( $block->inner_blocks ) ) {
			return true;
		}
	}

	return false;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 15:32:55

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: