WC_Template_Loader::force_single_template_filter()public staticWC 3.3.0

Force the loading of one of the single templates instead of whatever template was about to be loaded.

Method of the class: WC_Template_Loader{}

No Hooks.

Returns

String.

Usage

$result = WC_Template_Loader::force_single_template_filter( $template );
$template(string) (required)
Path to template.

Changelog

Since 3.3.0 Introduced.

WC_Template_Loader::force_single_template_filter() code WC 9.8.5

public static function force_single_template_filter( $template ) {
	$possible_templates = array(
		'page',
		'single',
		'singular',
		'index',
	);

	foreach ( $possible_templates as $possible_template ) {
		$path = get_query_template( $possible_template );
		if ( $path ) {
			return $path;
		}
	}

	return $template;
}