_resolve_home_block_template

函数
_resolve_home_block_template ( No parameters )
Access
Private
返回值
  • (array|null) A template object, or null if none could be found.
定义位置
相关方法
resolve_block_templatelocate_block_templatewp_enable_block_templatesget_block_templateget_the_block_template_html
引入
6.0.0
弃用
-

_resolve_home_block_template: 这个函数用于解决特定网站的首页模板。它通常在get_option函数中调用。

返回网站主页的正确模板。

function _resolve_home_block_template() {
	$show_on_front = get_option( 'show_on_front' );
	$front_page_id = get_option( 'page_on_front' );

	if ( 'page' === $show_on_front && $front_page_id ) {
		return array(
			'postType' => 'page',
			'postId'   => $front_page_id,
		);
	}

	$hierarchy = array( 'front-page', 'home', 'index' );
	$template  = resolve_block_template( 'home', $hierarchy, '' );

	if ( ! $template ) {
		return null;
	}

	return array(
		'postType' => 'wp_template',
		'postId'   => $template->id,
	);
}

常见问题

FAQs
查看更多 >
闪电侠

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

2025-12-05 18:32:58

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

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

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