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.

_add_template_loader_filters() WordPress Function

The add_template_loader_filters() function allows you to add your own filter functions to the list of template loader filters. This can be useful if you want to override the default behavior of the template loader.

_add_template_loader_filters() #

Adds necessary filters to use ‘wp_template’ posts instead of theme template files.


Source

File: wp-includes/block-template.php

function _add_template_loader_filters() {
	if ( ! current_theme_supports( 'block-templates' ) ) {
		return;
	}

	$template_types = array_keys( get_default_block_template_types() );
	foreach ( $template_types as $template_type ) {
		// Skip 'embed' for now because it is not a regular template type.
		if ( 'embed' === $template_type ) {
			continue;
		}
		add_filter( str_replace( '-', '', $template_type ) . '_template', 'locate_block_template', 20, 3 );
	}

	// Request to resolve a template.
	if ( isset( $_GET['_wp-find-template'] ) ) {
		add_filter( 'pre_get_posts', '_resolve_template_for_new_post' );
	}
}


Top ↑

Changelog

Changelog
VersionDescription
5.9.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.