get_block_theme_folders

函数
get_block_theme_folders ( $theme_stylesheet = null )
参数
  • (string) $theme_stylesheet The stylesheet. Default is to leverage the main theme root.
    Required:
    Default: null
返回值
  • (string[]) { Folder names used by block themes. @type string $wp_template Theme-relative directory name for block templates. @type string $wp_template_part Theme-relative directory name for block template parts. }
定义位置
相关方法
_get_block_templates_files_get_block_template_fileget_block_templatesget_block_templateget_block_categories
引入
5.9.0
弃用
-

get_block_theme_folders:此函数返回一个目录数组,其中可以存储特定主题的块模板。它不接受任何参数。

出于向后兼容的原因。

区块主题可能使用区块模板或区块模板-小工具,这个函数确保我们正确地回退到这些文件夹。

function get_block_theme_folders( $theme_stylesheet = null ) {
	$theme_name = null === $theme_stylesheet ? get_stylesheet() : $theme_stylesheet;
	$root_dir   = get_theme_root( $theme_name );
	$theme_dir  = "$root_dir/$theme_name";

	if ( file_exists( $theme_dir . '/block-templates' ) || file_exists( $theme_dir . '/block-template-parts' ) ) {
		return array(
			'wp_template'      => 'block-templates',
			'wp_template_part' => 'block-template-parts',
		);
	}

	return array(
		'wp_template'      => 'templates',
		'wp_template_part' => 'parts',
	);
}

常见问题

FAQs
查看更多 >
闪电侠

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

2025-12-14 21:36:41

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

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

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