WC_Brands::template_loader
- 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.
Method of the class: WC_Brands{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WC_Brands = new WC_Brands(); $WC_Brands->template_loader( $template );
- $template(required)
- .
WC_Brands::template_loader() WC Brands::template loader code WC 10.3.6
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;
}