WC_Brands::template_loader()publicWC 1.0

  • Handles template usage so that we can use our own templates instead of the themes.
  • Templates are in the 'templates' folder. woocommerce looks for theme overides in /theme/woocommerce/ by default
  • For beginners, it also looks for a woocommerce.php template first. If the user adds this to the theme (containing a woocommerce() inside) this will be used for all woocommerce templates.
  • @param string $template Template.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$WC_Brands = new WC_Brands();
$WC_Brands->template_loader( $template );
$template (обязательный)
-

Код WC_Brands::template_loader() WC 9.4.2

public function template_loader( $template ) {
	$find = array( 'woocommerce.php' );
	$file = '';

	if ( is_tax( 'product_brand' ) ) {

		$term = get_queried_object();

		$file   = 'taxonomy-' . $term->taxonomy . '.php';
		$find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
		$find[] = $this->template_url . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
		$find[] = $file;
		$find[] = $this->template_url . $file;

	}

	if ( $file ) {
		$template = locate_template( $find );
		if ( ! $template ) {
			$template = WC()->plugin_path() . '/templates/brands/' . $file;
		}
	}

	return $template;
}