Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_resolve_home_block_template() WordPress Function

The resolve_home_block_template() function is used to resolve the path to a home block template. This function is used by the WordPress block editor to determine the path to the home block template. It first looks for a template in the theme's directory, then falls back to the default template in the WordPress directory. This function is useful for customizing the home block template without having to override the entire block editor.

_resolve_home_block_template() #

Returns the correct template for the site’s home page.


Return

(array|null) A template object, or null if none could be found.


Top ↑

Source

File: wp-includes/block-template.php

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,
	);
}


Top ↑

Changelog

Changelog
VersionDescription
6.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.