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.

Метод класса: WC_Template_Loader{}

Хуков нет.

Возвращает

Строку.

Использование

$result = WC_Template_Loader::force_single_template_filter( $template );
$template(строка) (обязательный)
Path to template.

Список изменений

С версии 3.3.0 Введена.

Код WC_Template_Loader::force_single_template_filter() WC 8.7.0

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