_add_block_template_info

函数
_add_block_template_info ( $template_item )
Access
Private
参数
  • (array) $template_item Template to add information to (requires 'slug' field).
    Required:
返回值
  • (array) Template item.
定义位置
相关方法
_add_block_template_part_area_info_get_block_template_file_get_block_templates_fileslocate_block_templateget_block_template
引入
5.9.0
弃用
-

add_block_template_info: 这个动作用于添加块模板的信息,如名称、类别和描述。这些信息被块编辑器用来在模板选择器中显示该模板。

试图向模板项目添加自定义模板信息。

function _add_block_template_info( $template_item ) {
	if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) {
		return $template_item;
	}

	$theme_data = WP_Theme_JSON_Resolver::get_theme_data()->get_custom_templates();
	if ( isset( $theme_data[ $template_item['slug'] ] ) ) {
		$template_item['title']     = $theme_data[ $template_item['slug'] ]['title'];
		$template_item['postTypes'] = $theme_data[ $template_item['slug'] ]['postTypes'];
	}

	return $template_item;
}

常见问题

FAQs
查看更多 >
闪电侠

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

2025-12-14 21:36:41

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

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

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