wc_locate_template( string $template_name, string $template_path = '', string $default_path = '' )
Locate a template and return the path for inclusion.
Description Description
This is the load order:
yourtheme/$template_path/$template_name yourtheme/$template_name $default_path/$template_name
Parameters Parameters
- $template_name
-
(Required) Template name.
- $template_path
-
(Optional) Template path. (default: '').
Default value: ''
- $default_path
-
(Optional) Default path. (default: '').
Default value: ''
Return Return
(string)
Source Source
File: includes/wc-core-functions.php
function wc_locate_template( $template_name, $template_path = '', $default_path = '' ) { if ( ! $template_path ) { $template_path = WC()->template_path(); } if ( ! $default_path ) { $default_path = WC()->plugin_path() . '/templates/'; } // Look within passed path within the theme - this is priority. $template = locate_template( array( trailingslashit( $template_path ) . $template_name, $template_name, ) ); // Get default template/. if ( ! $template || WC_TEMPLATE_DEBUG_MODE ) { $template = $default_path . $template_name; } // Return what we found. return apply_filters( 'woocommerce_locate_template', $template, $template_name, $template_path ); }